I've been playing a bit with pointers and strings.
Why doesn't it matter (at least as far I can see) whether I do: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; }
orCode: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?Code:printf("pString has been stored here: %d", &pString);



LinkBack URL
About LinkBacks




