【发布时间】:2015-10-19 23:43:03
【问题描述】:
#include<stdio.h>
//This program is about structure and there pointer
//
typedef struct{
int i;
char c;
}str1,*strptr;
str1 str[5];
strptr *ptr;
int main(){
ptr = &str;// This is shown as incompatible type assignment **warning**
ptr->i=35; // **error**: request for member 'i' in something
//not a structure or union
ptr->c='d';//**error**: request for member 'c' in
// something not a structure or union
printf("My structure values are %d %c\n",str[0].i,str[0].c);
return 0;
}
当我运行这个程序时,会出现一个警告和两个错误。请阅读注释行以了解警告和错误。
我错过了什么?
【问题讨论】: