Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "functions.h"
- struct Items
- {
- char code[10];
- char description[30];
- int stock;
- };
- int main()
- {
- int x=0;
- int menu =0;
- struct Items MyItems[10];
- ReadFile(MyItems,10);
- printf("%s %s %d",MyItems[4].code,MyItems[4].description,MyItems[4].stock);
- }
- // functions.h
- void ReadFile(struct Items * arr, size_t len)
- {
- FILE * input;
- input = fopen("Items.txt","r");
- int x =0;
- while(!feof(input))
- {
- fscanf(input,"%[^,],%[^,],%d%*c", arr[x].code,arr[x].description,&arr[x].stock);
- x++;
- }
- fclose(input);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement