-4
我已经尝试了下面的书面代码,但它没有奏效。我可以知道为什么吗?是否有可能通过结构指针扫描结构成员?我们可以通过结构指针来扫描结构成员吗?
#include<stdio.h>
#include<conio.h>
struct book
{
int isdn;
float price;
};
struct book b,*ptr;
void main()
{
clrscr();
b.isdn=10;
b.price=150.75;
printf("\n%d %f",b.isdn,b.price);
ptr=&b;
printf("\n%d %f",ptr->isdn,ptr->price);
scanf("%d %f",&ptr->isdn,&ptr->price); //this statement do not work,why?
printf("\n%d %f",ptr->isdn,ptr->price);
getch();
}
它确实有效,它没有任何问题。 –
您是否真的在问为什么scanf不起作用? [whathaveyoutried.com](http://whathaveyoutried.com) – Sevki
顺便说一下,为什么你需要指针? '&b.price'不够好吗? – 2012-12-25 16:57:36