Doubt using C Pointers

Asked

Viewed 18 times

0

I wonder if there is any difference using %d instead of %p to return the pointers address. Using the %d operator is good programming practice?

int a, *aPtr;

aPtr = &a;

printf("Digite o valor de a : ");
scanf("%d",&a);

/*
printf("O valor de a e : %d \n",a);
printf("O valor de *a e : %d \n",*aPtr);

printf("\n");

printf("O endereco de a e %d \n",&a);
printf("O endereco de *aPtr e %d \n",aPtr);
*/

printf("O valor de a e : %d \n",a);
printf("O valor de *aPtr e : %d \n",*aPtr);

printf("O endereco de a e : %p \n",&a);
printf("O endereco de *aPtr e : %p \n",aPtr);
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.