关于数组越界的问题
程序代码:#include<stdio.h>
int main(void)
{
char st[20];
char *p;
int i;
i = 0;
p = st;
scanf("%s",p);
for (i = 0; st[i] != '\0'; i ++,p++)
{
if(*p == 'k')
{
printf("there is a 'k' in the strint\n");
break;
}
}
if (*p == '\0')
{
printf("there is no 'k' in the string\n");
}
return 0;
}
这个程序如果K出现在20个字符以后还能显示有个K在字符中,不知是编译器的问题,还是我想的不对![ 本帖最后由 rib 于 2010-3-20 08:08 编辑 ]








