Comment récupérer l'adresse de la variable pointeur en paramètre de fonction ?
Bonjour à tous,
Je ne vois pas comment faire avec la fonction stackDisplay pour afficher l'adresse de stockage du pointeur appelant.
Un petit code.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <stdio.h>
#include <stdlib.h>
void stackDisplay(int *);
int main()
{
int *p = malloc( sizeof *p);
if ( p == NULL) exit(1);
*p = 4;
printf("Address %p Value %p\n", &p, p);
printf("Address %p Value %d\n", p, *p);
stackDisplay(p);
free(p);
return 0;
}
void stackDisplay(int *_p)
{
printf("Pointer : \n");
printf("Address %p Value %p\n", &_p , _p);
printf("Address %p Value %d\n\n", _p , *_p);
} |