1
Personal my question is simple but makes me unable to work with pointers, the variable 'y' simply does not receive the address of x in the example below:
#include<stdlib.h>
#include <locale.h>
int main()
{
setlocale(LC_ALL, "portuguese");
int *y, x;
printf("Digite um numero: ");
scanf_s("%d", &x);
y = &x;
printf("Voce digitou o numero %d\n", y);
system("pause");
return 0;
}
Thank you all for your help
Like
y
is a pointer you should use:printf("Voce digitou o numero %d\n", *y);
. Print the content pointed byy
.– anonimo
That’s right, the literature I’m reading was incorrect at this point, at the time you print the contents of a pointer you need to type * before. Thanks!
– Ricardo Lima
If the literature you’re using is wrong at such a basic point I think it’s best to change literature.
– anonimo