出现Error executing xicl6.exe.?为什么会这样?

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct boom{
int x;
char y[10];
};

void B(boom &T);

void main()
{
boom T[10];
for(int i=0;i<10;i++){
scanf("%d %s",&T[i].x,T[i].y);
printf("%d %s\n",T[i].x,T[i].y);
}
B(T[10]);
}

void B(boom &T){
boom T1;
scanf("%d %s",&T1.x,T1.y);
for(int i=0;i<10;i++){
if(strcmp(T[i].y,T1.y)==0){
printf("hhhhh\n");
exit(0);
}
}
}

C:\Documents and Settings\Administrator\桌面\Text1.cpp(26) : error C2676: binary '[' : 'struct boom' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Documents and Settings\Administrator\桌面\Text1.cpp(26) : error C2228: left of '.y' must have class/struct/union type
Error executing xicl6.exe.

千万里不及你
浏览 199回答 2
2回答

隔江千里

void B(boom &T),这个函数期望参数是一个boom引用,而你传入的是一个级数头指针。

慕沐林林

试试 把 &T[i].y 改成 &((T[i]).y)
打开App,查看更多内容
随时随地看视频慕课网APP