The first ++ tried to modify what p points to.
Since p points to a string constant, your program dies because it tried to modify something in read-only memory. Read More
> char *p = &q;
Did you try it?
&q has a different type to q, so any good compiler would complain about incompatible pointer assignments. Read More
[QUOTE=jephthah;915989]yes, you're right.
even though it works for this trivial example, not casting it properly is a bad habit to get into.
the correct way to initialize it is:
char *p = [color=red][b](char *)[/b][/color]&q;
So you get the wrong type, then cast it to the right type … Read More
[QUOTE=tux4life;916334]A little addition on:
[QUOTE]Array names become pointers[/QUOTE]
Yes, an array name is a constant pointer to the first element of that array.[/QUOTE]
An array name is the name of an array object, nothing more, nothing less. When used as a value, it is converted to a pointer to the … Read More
It seems that most people other than Tom Gunn need to swing by here and have a nice long read.
[url]http://c-faq.com/aryptr/index.html[/url] Read More