home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- * CH09_06.C Jeux de tableaux et pointeurs *
- *********************************************************************/
-
- #include<stdio.h>
- #define dim 5
-
- main( void)
- {
- int i, tab[dim], *ptr= tab;
-
- /* Initialisation: */
- for( i= 0; i< dim; i++) *ptr++= i;
-
- /* Affichage: */
- ptr= tab; /* retour au dΘbut du tableau */
- for( i= 0; i< dim; i++)
- printf("\n rΘfΘrence: %d , tab[%d]= %d", ptr++, i, *ptr);
-
- /* Etat des lieux α la sortie de boucle: */
- printf("\n\n i: %d , rΘfΘrence: %d , pointeur: %d\n",
- i, ptr, *ptr);
-
- ptr-= 5; /* retour au dΘbut du tableau */
- printf("\n rΘfΘrence: %d , pointeur: %d", ptr, *ptr);
-
- *ptr++;
- printf("\n rΘfΘrence: %d , pointeur: %d", ptr, *ptr);
-
- (*ptr)++;
- printf("\n rΘfΘrence: %d , pointeur: %d", ptr, *ptr);
-
- *++ptr;
- printf("\n rΘfΘrence: %d , pointeur: %d", ptr, *ptr);
-
- ++*ptr;
- printf("\n rΘfΘrence: %d , pointeur: %d\n", ptr, *ptr);
-
- /* Affichage: */
- ptr= tab; /* retour au dΘbut du tableau */
- for( i= 0; i< dim; i++)
- printf("\n rΘfΘrence: %d , tab[%d]= %d", ptr++, i, *ptr);
- }
- /*
- rΘfΘrence: 6846 , tab[0]= 0
- rΘfΘrence: 6848 , tab[1]= 1
- rΘfΘrence: 6850 , tab[2]= 2
- rΘfΘrence: 6852 , tab[3]= 3
- rΘfΘrence: 6854 , tab[4]= 4
-
- i: 5 , rΘfΘrence: 6856 , pointeur= 6866
-
- rΘfΘrence: 6846 , pointeur= 0
- rΘfΘrence: 6848 , pointeur= 1
- rΘfΘrence: 6848 , pointeur= 2
- rΘfΘrence: 6850 , pointeur= 2
- rΘfΘrence: 6850 , pointeur= 3
-
- rΘfΘrence: 6846 , tab[0]= 0
- rΘfΘrence: 6848 , tab[1]= 2
- rΘfΘrence: 6850 , tab[2]= 3
- rΘfΘrence: 6852 , tab[3]= 3
- rΘfΘrence: 6854 , tab[4]= 4 */
-
-
-
-