在下面的程序中,我没有从printf
.
#include<stdio.h>
int main()
{
struct book
{
char name;
float price;
int pages;
};
struct book b1,b2,b3;
printf("enter names prices & no. of pages of 3 books\n");
scanf("%c %f %d",&b1.name,&b1.price,&b1.pages);
fflush(stdin);
scanf("%c %f %d",&b2.name,&b2.price,&b2.pages);
fflush(stdin);
scanf("%c %f %d",&b3.name,&b3.price,&b3.pages);
fflush(stdin);
printf("and this is what you entered\n");
printf("%c %f %d",&b1.name,&b1.price,&b1.pages);
printf("%c %f %d",&b2.name,&b2.price,&b2.pages);
printf("%c %f %d",&b3.name,&b3.price,&b3.pages);
return 0;
}
我得到的这个输出
enter names prices & no. of pages of 3 books
a 34.6 23
b 23.4 34
c 63.5 23
and this is what you entered
0.000000 0∞ 0.000000 0╪ 0.000000 0Press any key to continue . . .
为什么输出与输入不匹配?