5
Initialisation d'un tableau
- #include <stdio.h>
- #define TABSIZE 4
- main() {
- int tab1[ TABSIZE ] = { 1, 2, 3, 4 };
- int tab2[ TABSIZE ] = { 1, 2 };
- int tab3[] = { 1, 2, 3, 4, 5 };
- int i;
- for ( i = 0; i < TABSIZE; i++ )
- printf("%d: %d\n", i+1, tab1[ i ]);
- printf("\n");
- for ( i = 0; i < TABSIZE; i++ )
- printf("%d: %d\n", i+1, tab2[ i ]);
- printf("\n");
- for ( i = 0; i < sizeof( tab3 ) / sizeof( int ); i++ )
- printf("%d: %d\n", i+1, tab3[ i ]);
- }
Commentaires