关于typedef 定义结构体指针赋值的问题
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct per
{
char name[20];
char add[20];
int age;
}Person; 如果将下面给的 Person *s 合并到这里: Person,*s; 当执行到s=a的时候 编译就出错 为什么呢?
int main(void)
{
Person *s;
int i;
char *p;
Person a[3]={
{"강민","서울",10},
{"김강","울산",12},
{"박수","대구",9}
};
s=a;
printf("plesae input a string.\n");
scanf("%s",p);
for(i=0;i<3;i++,s++)
if(strcmp(s->name,p)==0)
{
printf("find the people\nthis people's informatation as fallow\n");
printf("%s\t%s\t%d",s->name,s->add,s->age);
}
else
{
printf("NO this people.\n");
exit(0);
}
用 vs 2010 编译可以通过 但是如果按照上面修改了以后就不行
程序可能不完善 还有错的地方 请大家帮忙改改