I found a few errors.
Compare to this...
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAXINPUT 20 //use this value to max loop (apply later)
struct Book {
char title[10];
int pages;
};
int main() {
int i = 0, option = 0, bookCount = 0;
struct Book books[10];
while (i < 10) {
printf("Do you want to enter details of BOOK 1 (yes) or 0 (No)? ");
scanf("%d", &option);
if (option == 1) {
printf("\n Title name: ");
scanf("%s", books[i].title);
printf("\n Number of pages: ");
scanf("%i", &books[i].pages);
bookCount++;
} else if (option == 0) {
printf("It was not yes \n");
break;
} else {
printf("Valid input, go back to main menu \n");
break;
};
i++;
};
// save records to file// to be written
//display records created
for (i = 0; i < bookCount; i++) {
printf("Book title: ");
puts(books[i].title);
printf("Page number: %d", books[i].pages);
printf("\n");
};
//display all saved record//to be written
return 0;
};
tried to keep it close to the original.