C语言错误 left of '.name' must have struct/union type

问题描述:

C语言错误 left of '.name' must have struct/union type
#include
#include
#include
#include"me.h"
void pr_4()
{
\x05int a=0;char ch;int n=0;
\x05char *numstr;
\x05char *SongInfo;
if((fp=fopen("SongInfo.dat","rb"))==NULL)
\x05{
\x05printf("\ncannot open file \n");
\x05exit(0);
\x05}
\x05while(fread(&SI,sizeof (struct SongInfo),1,fp)==1)
\x05\x05n++;
\x05 a=n;
\x05\x05printf("请输入查询方式\n");
\x05\x05printf("1 歌曲名称 2 歌曲作者 3 歌曲演唱者\n");
ch=getchar();getchar();
\x05\x05switch(ch)
\x05\x05{
\x05\x05case 1:
\x05\x05\x05\x05 printf("请输入要查找歌曲名称:\n");
\x05\x05\x05\x05 gets(numstr);
\x05\x05\x05\x05 for(n=0;n
1个回答 分类:综合 2014-10-31

问题解答:

我来补答
SongInfo 必须是一个已经定义的结构体,才能用 SongInfo[ n ].name 语句成立
错误信息提示你 SongInfo 不是一个结构体或者联合体
再问: 头文件里定义过了
再答: 然后你又定义了一个 char * SongInfo 字符串变量 导致变量名重复,所以编译器报错
 
 
展开全文阅读
剩余:2000