请教一个简单问题
请教:如果想输入一段字符,以“!”结尾,下面程序为什么不对
#include<stdio.h>
main()
{
char str[20];
int i;
for(i=0;str[i]!='!';i++)
{
scanf("%c",&str[i]);
}
}
请教:如果想输入一段字符,以“!”结尾,下面程序为什么不对
#include<stdio.h>
main()
{
char str[20];
int i;
for(i=0;str[i]!='!';i++)
{
scanf("%c",&str[i]);
}
}
2006-08-07 10:48
2006-08-07 10:54
2006-08-07 11:01

2006-08-07 11:28
2006-08-07 11:33

2006-08-07 12:24
2006-08-07 13:37

2006-08-07 14:24

2006-08-07 14:32
#include<stdio.h>
void main()
{
char str[20];int a=0;
for(int i=0;i<20;i++)
{ scanf("%c",&str[i]);
a++;
if(str[i]=='!')goto end;
}
end:for( i=0;i<a;i++)
printf("%c",str[i]);
}

2006-08-07 15:05