Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FILE* file = 0;
- char filename[25];
- printf("Saving grocery list to test.bin...n");
- errno_t errorCode = fopen_s(&file, "test.bin", "wb"); //This line is different
- //because of MVS...
- if (file == NULL )
- {
- printf("File could not be opened.n");
- return 0;
- }
- else
- {
- fwrite(&totalGrocery, sizeof(int), totalGrocery, file);
- fwrite(&item, sizeof(struct grocery), totalGrocery, file);
- fclose(file);
- printf("The file has now been saved.n");
- }
- struct grocery
- {
- int id;
- char food[31];
- float quantity;
- char unit[16];
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement