#include
#include
#include
#define SIZE 3//不能加;
char *AAA(char *str);
int main()
{
char str[SIZE][30];
char ch;
printf("enter three stences\n");
for (int i = 0; i<3; i++)
fgets(str[i], 30, stdin);
ch = getchar();
getchar();
while (ch != 'q')
{
switch (ch)
{
case 'a': AAA(str[SIZE]); break;
default: printf("enter data error!\n"); break;
}
printf("Continue Or Enter 'q'to quit\n");
ch = getchar();
getchar();
}
system("pause");
return 0;
}
char *AAA(char *str)
{
for (int i = 0; i < SIZE; i++)
fputs(str++, stdout);
return 0;
}
如果函数是使用
char *AAA(char str[SIZE][30])
{
for (int i = 0; i < SIZE; i++)
fputs(str[i],stdout);
return 0;
}
则一切正常,而使用指针就会输出烫。
希望有人能指点一下原因,感激不尽!