Hi, I am a newbie in C, and I have just moved to the Structures Chapter in my text. This is the first program here.
And the output:
struct book b1,b2,b3;
printf("\nEnter names, prices, and no. of pages of 3 books.\n\n");
scanf("%c %f %d",&b1.name,&b1.price,&b1.pages);
scanf("%c %f %d",&b2.name,&b2.price,&b2.pages);
scanf("%c %f %d",&[b3.name,&b3.price,&b3.pages);
printf("\n\nAnd this is what you have entered.\n\n");
printf("\n%c %f %d",b1.name,b1.price,b1.pages);
printf("\n%c %f %d",b2.name,b2.price,b2.pages);
printf("\n%c %f %d",b3.name,b3.price,b3.pages);
The compiler(GCC here) takes in the values of only two struct variables b1 and b3. I don't think anything is wrong with my code as I have copied it from the text.
Enter names, prices, and no. of pages of 3 books.
A 100 100
B 100 100
And this is what you have entered.
A 100.000000 100
B 100.000000 100