程序的输出为什么是这样?
#include "string.h"
#include "stdio.h"
static char* fullpath;
int main(int argc, char* argv[])
{ char *part="second";
fullpath=(char*)malloc(100);
fullpath="first";
//printf("%s\n",part);
printf("%s\n",fullpath);
getchar();
strcat(fullpath,part);
printf("%s\n",fullpath);
getchar();
return 0;
}输出为
first
d
如果我把//去掉,输出正常:
second
first
firstsecond
为什么呢?