二维数组报错
#include <stdio.h>int main ()
char a[]={{' ',' ','*',' ',' '},{' ','*',' ','*',' '},{'*',' ',' ',' ','*'},{' ',' ','*',' ',' '},{' ',' ','*',' ',' '}};
int x,y;
for(x=0;x<5;x++)
{
for(y=0;y<5;y++)
{
printf("%c",a);
}
printf("\n");
}
}
有错误 parameter 'a' is initialized不知道是什么情况
还有好多的warning braces around scalar initializer5 (near initialization for 'a') 哦,解决了,谢谢大家
我括号没加 少了一个左大括号,改成这样:
#include <stdio.h>
int main ()
{// 这里少了一个括号
char a[]={{' ',' ','*',' ',' '},{' ','*',' ','*',' '},{'*',' ',' ',' ','*'},{' ',' ','*',' ',' '},{' ',' ','*',' ',' '}};
int x,y;
for(x=0;x<5;x++)
{
for(y=0;y<5;y++)
{
printf("%c",a);
}
printf("\n");
}
}
页:
[1]