I'm writing a program to input book information using typedef and function.
Here is my declaration using typedef:
typedef struct {
char name[1000], author[1000], publisher[1000], description[1000], ISBN[15];
} book;
Here is the function used to add book info:
void addBook(int* n, book list[1000]) {
printf("Enter number of book you want to add: ");
fpurge(stdin);
scanf("%d", n);
int i;
for (i = 0; i < *n; i++) {
printf("Book title: ");
fpurge(stdin);
gets(list[i].name);
printf("Book author: ");
fpurge(stdin);
gets(list[i].author);
printf("Publisher: ");
fpurge(stdin);
gets(list[i].publisher);
printf("Description: ");
fpurge(stdin);
gets(list[i].description);
printf("ISBN: ");
fpurge(stdin);
gets(list[i].ISBN);
}
}
And the final is main:
int main(int argc, char** argv) {
int n, list[1000];
addBook(&n, list);
return (EXIT_SUCCESS);
}
So when I tried to run, it worked. However, the compiler showed me two warning:
warning: passing argument 2 of 'addBook' from incompatible pointer type [-Wincompatible-pointer-types]
expected 'book *' but argument is of type 'int'
My question is: Are these warnings considered as errors? If yes, what is the correct solution? If no, why the compiler showed it?
P/s: I use Netbean IDE.