It's been so long since I even wrote anything in C/C++. But I've been thinking about pointers lately and trying to remember whats safe about them and whats not.
Lets say I do this.
'name' is really just an integer that has the location in memory of the letter 'P'. Somewhere burried deep inside my computers memory are 13 characters in a string:Code:char * name = "Paul Stovell";
Using * in front of the name after it is declared, for example:Code:| P | A | U | L | | S | T | O | V | E | L | L | \0 |
I am dereferencing the pointer. If I just used 'name' I would be assigning a char array to an integer, which would be incorrect. But with *, I am saying "get me the char array that 'name' points to".Code:*name = "John";
Is this understanding correct?
Because the 'name' variable is really just an integer, I can use ++, --, or all the other integer operators (correct?). When I do:
name++, I am saying "Name now points to the memory location one byte after its current location".
If this is true, how sure can we be those bytes will always be in a sequential order? And, how sure can we be that the character at position name+13 is always '\0'?