#include #include #include char *expand(char *p) { int len; char *q, ch; /* (1) */ len = strlen(p); /* (2) */ /* (3) */ strcpy(q, p); /* (4) */ /* (5) */ free(p); /* (6) */ return q; } int main(void) { int i, n; char *str; str = malloc(sizeof(char)*2); str[0] = 'a'; str[1] = '\0'; printf("繰り返し回数を入力してください:"); scanf("%d", &n); for ( i = 1; i <= n; i++ ) { str = expand(str); printf("%3d:[%s]\n", i, str); } return 0; }