I've been playing a bit with pointers and strings.
Code:
#include <stdio.h>
int main()
{
char string; //Sets up a character named string.
char * pString = &string; //Makes a character pointer and assings the adress of string to it
puts("Enter: ");
scanf(" %s", pString); //I know this could have been gets(), I used scanf().
printf("%s\n",pString);
printf("pString has been stored here: %d", pString);
getchar();
getchar();
return 0;
}
Why doesn't it matter (at least as far I can see) whether I do:
Code:
printf("pString has been stored here: %d", pString);
or
Code:
printf("pString has been stored here: %d", &pString);
The ampersand is the adress of operator in this case, so why can I get the adress without using it? Did I miss something about pointers perhaps?