strcpy的越界问题
void test1()
{
char string[10];
char* str = "0123456789";
strcpy(string, str);
std::cout << string << std::endl;
}
strcpy函数中while((*address++ = *strSrc++) != '\0'); address与strDest指向同一个地址,
那么上面的test1函数中在&string+1处的值不是改变成了'\0'了么?为什么不发生运行时错误?
{
char string[10];
char* str = "0123456789";
strcpy(string, str);
std::cout << string << std::endl;
}
strcpy函数中while((*address++ = *strSrc++) != '\0'); address与strDest指向同一个地址,
那么上面的test1函数中在&string+1处的值不是改变成了'\0'了么?为什么不发生运行时错误?
...全文


