Question: source code and script files, please. (dict.h) /* dict.h header for data dictionary routines. */ #include struct dict_elem{ char d_name[15]; // name of dictionary member

source code and script files, please.

(dict.h)

/* dict.h header for data dictionary routines. */

#include

struct dict_elem{ char d_name[15]; // name of dictionary member int d_start; //starting position in record int d_length; //length of field int d_type; //denotes type of data };

#define ERROR (-1) #define SUCCESS 0

(dictionary.c)

#include "dict.h"

int writedict(const char *dictname, struct dict_elem *elist){

int j; FILE *outf;

if ((outf = fopen(dictname, "w")) == NULL){ return ERROR; }

//cculate length of the aray for (j = 0; elist[j].d_length != 0; j++) ;

//write out list of dict_elem structures if (fwrite((void*)elist, sizeof(struct dict_elem), j, outf) fclose(outf); return ERROR; }

fclose(outf); return SUCCESS; }

//**************************

struct dict_elem * readdict(const char *dictname, struct dict_elem *inlist, int maxlength) {

int i; FILE *inf;

if ((inf = fopen(dictname, "r")) == NULL){ return NULL; } //read in dict_elem structures from file for (i = 0; i { if (fread((void*)&inlist[i], sizeof(struct dict_elem), 1, inf) { break; } }

fclose(inf);

//mark end of list inlist[i].d_length = 0;

return inlist; }

// your main function goes here. int main(void) {

// struct dict_elem array[3] ={ {}, {},{} , {} }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!