ポインタ配列


#include <stdio.h>
void main()
{
 char *str[] = { "Candy", "Nancy", "Eluza", "Ann" };
 int i, j;

 // 1行ずつ出力
 for ( i=0; i<4; i++ )
  printf( "%s\n", str[ i ] );

 // 1文字ずつ出力
 for ( i=0; i<4; i++ ) {
  j = 0;
  while ( str[ i ][ j ] != '\0' ) {
   putchar( str[ i ][ j ] );
   j++;
  }
  putchar( '\n' );
 }
}

C > ポインタ | comments (0) | trackbacks (0)

Comments

Comment Form

icons:

Trackbacks