#include
#include
struct container {
int number;
char *string;
};
int main()
{
struct container *c;
c = malloc(sizeof(struct container));
if (c == NULL) exit(1);
scanf("%d", &c->number);
scanf("%s", c->string);
printf("%d:%s\n", c->number, c->string);
free(c);
return 0;
}
一運行就崩潰
問如何改正
container裡面string只是個char型指針,沒有分配內存