Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C/C++: Incrémenter un pointeur à l’aide de l’opérateur ‘++’

 pointeur, adresse
Download

 
#include <iostream>
 
using namespace std;
 
const int Lengh = 3;
 
int main ()
{
 
         int tab[] = {10, 9, 8, 7, 6
                ,5, 4, 3, 1, 0};
 
	  int size=sizeof(tab)/sizeof(tab[0]);
 
	  /* Le nom du tableau est un pointeur */
   int* pointeur_int = tab;
 
   /*
     chaque incrémentation du pointeur renvoie
     l'élément suivant du tableau.
  */
   for (int i = 0; i < size; i++, pointeur_int++)
   {
      cout<<"Adresse de l'index "<< i << "="<< pointeur_int
      << ", sa Valeur= " << *pointeur_int << endl;
   }
   return 0;
}
----------------------------------------------------------------------------

No comments yet.

Leave a Comment