2012-03-18 strdup C言語 strdupは引数に与えられた文字をmallocで領域確保して、そのポインタを返す char c[100] = "test test test"; char *c2; c2 = strdup(c); /* このコメント部分のようにはできない strcpy(c2, c); printf("1 ==> %s", c2); */