Posted by: testdirector August 4, 2005
Login in to Rate this Post:
0
?
![](/wysiwyg/editor/images/smiley/msn/thumbs_up.gif)
![10 more flags than likes deactivates post.](/wysiwyg/editor/images/smiley/msn/thumbs_down.gif)
Well I've to accept I'm terribly mistaken, assuming K&R is saying so - I probably have screwed up big time, despite the fact I've readily available compilers to support what I said.
I have not read K&R recently and do not have a copy of it right now, I'll get one from the library. I wonder what the ANSI and ISO are saying. But, beside having to blame the standards, I've the following point to make :
If "abcde" is a constant value to be stored in read-only areas, the compiler should stop there and give an error, saying a type mismatch. The case in point is,
const char p[] = "abcde";
char *q = p; /* Error. an attempt to assign different typed values */
The same way, if a compiler is smart enough to put "abcde" in rom in the following example,
char *p = "abcde";
the compiler should not compile it for the same reason.
Because the standard is against what I'm saying, I accept I was and am totally wrong.
Thank you for all the information you have given. I do not want to blame the standards. I do not want to say anything b4 I read (this is a big lesson for me), but I wonder what Bjarne Stroustroup has to say.