用指针间接赋值方法拷贝字符串为什么会出错?
//为什么在运行下面这个程序时,编译可以通过,但是程序会崩溃掉?
void main()
{
char from[128];
char to[128] = { 0 };
char *p1 = from;
char *p2 = to;
strcpy(from, "123234dsfdsf");
while(p1 != '\0')
{
*p2 = *p1;
p2++;
p1++;
}
printf("to: %s\n", from);
}