I gave the following input in the below code
a 12.5 12
b 13.5 13
c 14.5 14
#include <stdio.h>
int main(){
struct book
{
char name;
float price;
int pages;
};
struct book b1,b2,b3;
printf("enter name , price ,& no of pages\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("%c %d %f %d %d %d",b1.name,&b1.name,b1.price,&b1.price,b1.pages,&b1.pages);
printf("\n%c %d %f %d %d %d",b2.name,&b2.name,b2.price,&b2.price,b2.pages,&b2.pages);
printf("\n%c %d %f %d %d %d",b3.name,&b3.name,b3.price,&b3.price,b3.pages,&b3.pages);
printf("\n%d %d %d",sizeof(b1.name),sizeof(b1.price), sizeof(b1.pages));
}
And I got the following output
a 2686740 12.500000 2686744 12 2686748
b 2686728 13.500000 2686732 13 2686736
c 2686716 14.500000 2686720 14 2686724
1 4 4
Now what I can't understand is that the difference between the address of b1.name(2686740) and b1.price(2686744) is 4 wheres b1.name is a character so the difference should have been 1 and the same is repeated in b2 and b3 also. Please help!!!