程序是这样的:
#include<iostream>
#include<cstring>
using namespace std;
void main()
{
char *v1="a little boy ";
char *v2="a little girl";
strcat(v1,v2);//我理解错误,认为指针和数组名反正一样,编译器连错都不报就给我轰出来了!
cout<<v1<<endl;
}
修改后的程序:
#include<iostream>
#include<cstring>
using namespace std;
void main()
{
char v1[]="a little boy ";
char v2[]="a little girl";
strcat(v1,v2);//这次顺利通过了!
cout<<v1<<endl;
}