#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <process.h>
#include <string.h>
char * Strcpy(char *Dest,char *Src)
{
char *p=Dest;
while(*Src!='\0')
*Dest++=*Src++;
return p;
}
main()
{
char *p="abcdefg";
char *p2=NULL;
p2=(char *)malloc(sizeof(p));
if(p2==NULL)
{
printf("Not enough memory to allocate buffer");
exit(1);
}
Strcpy(p2,p);
printf("%s",p2);
free(p2);
}
结果出错:abcdefg?葺葺葺葳