1.char* a = "test";中a中存的值不能改,如*a = 'a';就会报错,所以下面这么做会出错
#include<iostream>
int main()
{
char *a = "k";
char b[5]= "test";
strcpy(a,b);//a中的值不可修改
std::cout<<b;
system("pause");
}
2.strcpy不接受NULL指针,如
#include<iostream>
int main()
{
char *a = NULL;
char b[5]= "test";
strcpy(b,a);//不接受NULL指针
std::cout<<b;
system("pause");
}