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

Author:

 pointeur, adresse
Download


#include 

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;
}

Leave a Reply

Your email address will not be published. Required fields are marked *