0
#include <stdio.h>
main()
{
float valor;
printf("...");
scanf("%f", &valor);
printf("%0.2f", valor);
}
In scanf I must refer to the pointer (memory space), already in printf this reference is not valid. What is the most coherent explanation?
C has no reference.
– Maniero
When you pass
valorat theprintf, you are passing the contents of the variable (which is exactly what this function needs, since its task is to print this value). Already for the functionscanfIt would be useless to pass a value, what it needs is a place to store the value that the user informs. It needs a memory address to do this, so it gets a pointer. That’s because in C the arguments are always passed by value.– bfavaretto
Doubt clarified. Thank you. Finally, in C, this symbol has some special name?
– Fábio Jânio
That operator
&is called "address-of".– bfavaretto