我的程序无结果?

来源:百度知道 编辑:UC知道 时间:2024/05/13 06:50:13
#include <iostream>
using namespace std;
char*strcopy(char*dest,char*source);
int main()
{
char*source="hello";
char*dest;
char*add;
add=strcopy(dest,source);
cout<<"字符串的首地址为:"<<dest<<endl;
return 1;
}
char *strcopy(char*dest,char*source)
{
strcpy(dest,source);
char *it=dest;
return it;
}
请高手帮忙看以下怎么回事?

老大,真服了你了,申请了字符串指针但是没有分配内存你也敢操作?没有提示非法操作,算你幸运了哈.

至少dest,add,it指针必须要申请内存.
如:dest=new char[100];