I think I might have figured out the problem I was having this morning.
Here's the Truth Nugget: Just because an array can behave like a pointer in some ways, doesn't mean it IS a pointer.
So the problem before was that if I have an array s[10], then just using s in an expression is using the address of the first element of the array - kind of like a pointer.
so:
char s[10];
char *ptr;
I can say:
ptr = s, without having to say explicitly ptr = &s[0] or something like that.
HOWEVER it doesn't go the other way.
I can't say s = ptr.
Why? Because.
DDT. Don't Do That.
Big thanks to http://www.eskimo.com/~scs/cclass/krnotes/sx8c.html
That site has saved me several times. I'd pay good money to have all those notes in a book.
http://stackoverflow.com/questions/232303/so-you-think-you-know-pointers/232369#232369
ReplyDelete