C/C++: Passage de paramètre par pointeur

Author:

 pointeur
Download


#include 

void fonction_test(char *msg, int *nombre, int *carre)
{
  printf(msg);
  scanf("%d", nombre);
  *carre=(*nombre * *nombre);
}

int main(void)
{
  int i;
  int nbr_carre; // nombre au carré
  /* Le poiteur 'i' est modifié dans la fonction */
  fonction_test("Tapez un nombre: ", &i, &nbr_carre);
  printf("Votre nombre: %d, son carré est:%dn", i, nbr_carre);

  return 0;
}

Leave a Reply

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