M
Michael
Hi,
In some code in my header file I have:
typedef struct{
int book_id;
char title[MAX_TITLE_SIZE];
char author[MAX_AUTHOR_SIZE];
int year;
int price;
int quantity;
}Book;
then later on I have:
Book *new_book;
char temp_title[MAX_TITLE_SIZE];
char temp_author[MAX_AUTHOR_SIZE];
if((new_book = malloc(sizeof(Book))) == NULL){
printf("Error allocating memory for new book");
}
new_book.book_id = new_book_id;
When I compile this I get errors that say "request for member book_id in
somehing not a structure or union".
I dont understand. I have Book as a structure and I have made new_book type
Book.
Can anyone help me here please....
Regards
Michael
In some code in my header file I have:
typedef struct{
int book_id;
char title[MAX_TITLE_SIZE];
char author[MAX_AUTHOR_SIZE];
int year;
int price;
int quantity;
}Book;
then later on I have:
Book *new_book;
char temp_title[MAX_TITLE_SIZE];
char temp_author[MAX_AUTHOR_SIZE];
if((new_book = malloc(sizeof(Book))) == NULL){
printf("Error allocating memory for new book");
}
new_book.book_id = new_book_id;
When I compile this I get errors that say "request for member book_id in
somehing not a structure or union".
I dont understand. I have Book as a structure and I have made new_book type
Book.
Can anyone help me here please....
Regards
Michael