I have learned that a pointer points to a memory address so i can use it to alter the value set at that address. So like this:
int *pPointer = &iTuna;
pPointer here has the memory address of iTuna. So we can use pPointer to alter the value at iTuna. If I print pPointer the memory address gets printed and if I print *pPointer then the value at iTuna gets printed
Now see this program
char* pStr= "Hello !";
cout<< pStr << endl;
cout<< *pStr << endl;
system("PAUSE");
return 0;
There are a lot of stuff I don't understand here:
In "Hello !" Each letter is stored separately, and a pointer holds one memory address. So how does
pStrpoint to all the letters.Also When I print out
pStrit prints Hello !, not a memory address.And when I print out
*pStrit prints out H only not all whatpStris pointing too.
I really can't understand and these are my concerns. I hope someone can explain to me how this works ad help me understand
char* pStr= "Hello !";is deprecated, usechar const*.cin.syncbefore callingcin.get. Or you can just use it like a normal console application instead of trying to make it a standalone app.