struct book{
char code[5];
char title[30];
char category[15];
char author[30];
float price;
};
struct book book[100];
book[0].price = 1;
It is giving error on the last line
struct book{
char code[5];
char title[30];
char category[15];
char author[30];
float price;
};
struct book book[100];
book[0].price = 1;
It is giving error on the last line
You do not need the struct tag in the variable declaration.
#include <stdio.h>
int main(){
struct book{
char code[5];
char title[30];
char category[15];
char author[30];
float price;
};
book books[100];
books[0].price = 1.0;
printf("%f/n" ,books[0].price);
return 0;
}
Try declaring your struct as follows:
struct book{
char code[5];
char title[30];
char category[15];
char author[30];
float price;
}sBook;
sbook book[100];
book[0].price = 1;
I hope I have helped!
To resolve, change the name of the vector, for example, to books.
struct book books[100];
Then when assigning a value of 1 to a float, do this:
books[0].price = 1.0;