Create linked list with embedded structure from input file in C -
Create linked list with embedded structure from input file in C -
i seek create linked list input file in c. node contains construction , think problem is. pointer phone call input info file pnew.stock.szstocknumber. have never called construction embedded in construction , new pointers. error when compiling:
cs1713p4.c:107: error: request fellow member ‘stock’ in not construction or union cs1713p4.c:108: error: request fellow member ‘stock’ in not construction or union cs1713p4.c:109: error: request fellow member ‘stock’ in not construction or union cs1713p4.c:110: error: request fellow member ‘stock’ in not construction or union
i appreciate help cuz cannot find info online nodes contain structures. thanks!
typedef struct node { stock stock; // contains inventory info struct node *pnext; // next node in linked list } node; void getinventory(node **pphead, char *pszinventoryfilename) { char szinputbuffer[100]; // input buffer reading info int = 0; // subscript in stockm int iscanfcnt; // returned sscanf file *pfileinventory; // stream input inventory data. stock stocktemp; node *pnew = null; node *pprecedes = null; /* open inventory stream info file */ if (pszinventoryfilename == null) exiterror(err_missing_switch, "-i"); pfileinventory = fopen(pszinventoryfilename, "r"); if (pfileinventory == null) exiterror(err_inventory_filename, pszinventoryfilename); /* inventory info until eof ** fgets returns null when eof reached. */ while (fgets(szinputbuffer, 100, pfileinventory) != null) { iscanfcnt = sscanf(szinputbuffer, "%6s %ld %lf %30[^\n]\n" , pnew.stock.szstocknumber , &pnew.stock.lstockqty , &pnew.stock.dunitprice , pnew.stock.szstockname); pnew->pnext = *pphead; *pphead = pnew; if (iscanfcnt < 4) exiterror(err_invalid_inventory_data, "\n"); if (pnew == null) exiterror("memory allocation error", ""); i++; } }
list file input structure
Comments
Post a Comment