通过指针输出结构体变量的内容
#include<stdio.h>#include<stdlib.h>
struct student
{
int ID;
char name;
};
int main()
{
struct stdent *p;
struct student first
={2016080227,"Tom"};
p=&first;
printf("%\n ID is %d",(*p).ID);
printf("\n name is %s",(*p).name);
return 0;
}
编译
c(13) : warning C4133: '=' : incompatible types - from 'struct student *' to 'struct stdent *‘
c(14) : error C2037: left of 'ID' specifies undefined struct/union 'stdent'
c(15) : error C2037: left of 'name' specifies undefined struct/union 'stdent'
第一:struct stdent *p;是student
第二:printf("%\n ID is %d",(*p).ID);把前面的%号去掉 最后的魁拔 发表于 2020-3-1 11:57
第一:struct stdent *p;是student
第二:printf("%\n ID is %d",(*p).ID);把前面的%号去掉
谢谢
页:
[1]