C Structure and file management
a) Create a structure that contains information about a book, title, actor and year of publication.
b) Write a function that saves the structure to a file, without deleting the information in the file.
c) Write a function that reads the file and writes out the titles.
My unfinished code:
Code:
#include <stdlib.h>
#include <stdio.h>
int main(){
int i;
typedef struct books {
char title[25];
char author[50];
int year;
int page;
}books;
books[10];
/*
FILE * post;
post= fopen("post.txt", "w+" );
while(!feof(post)){
flose(post)
*/
//Add book
while (i < 10 && books.b[i].titel[0] == '\0'){
printf("\nTitle: ");
scanf("%s", books.b[i].title);
printf("\nAuthor: ");
scanf("%s", b[i].author);
printf("\nYear: ");
scanf("%d", &b[i].year);
printf("\nPage: ");
scanf("%d", &b[i].page);
}
return 0;}