69,382
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string.h>
typedef struct T
{
char *name;
int num;
}test;
int main()
{
test *p = (test*)malloc(sizeof(test));
strcpy(p->name,"jim");
printf("%s\n",p->name);
return 0;
}
int main()
{
char *name;
strcpy(name,"jimy");
return 0;
}
又不会发生错误呢
test *p = (test*)malloc(sizeof(test));
p->name = (char*)malloc(64*sizeof(char));//64是你放的最多的字符数
strcpy(p->name,"jim");