关于while (*str)的判断问题,字符串数组和字符串指针的判断条件不同吗
定义的函数:
int replace(char *str, char c1, char c2)
{
int cnt = 0;
while (*str)
{
if (*str == c1)
{
*str = c2;
cnt++;
}
str++;
}
return cnt;
}
对于两个字符串:
char *a = "abccx";
char b[6] = "cdccy";
调用函数时,b作参数运行正常,a作参数时报错。显示.exe停止运行
请问是什么原因?a,b有何区别