#include #define MAXCHAR 'Z' - 'A' + 1 /* 'A' から 'Z' 文字分の配列を確保 */ void main () { char str[MAXCHAR]; /* ※文字数分の配列であって文字列ではない */ char *strptr = str; int index; for (index = 0; index < MAXCHAR; index++) { *strptr = index + 'A'; putchar(*strptr++); } printf("\n"); strptr = str; for (index = 0; index < MAXCHAR; index++) { putchar(*strptr++); } printf("\n"); } /* void main () { char str['Z' - 'A' + 1]; int index; for (index = 'A'; index <= 'Z'; index++) { str[index - 'A'] = index; } for (index = 0; index <= 'Z' - 'A'; index++) { putchar(str[index]); } printf("\n"); } */