Posted by: testdirector August 2, 2005
Information technology
Login in to Rate this Post:     0       ?        
well, I failed to understand what he wants; assuming he wants a copy which he expressed in his second posting, there is a discrepancy between the original two examples. It will be manifested by different behaviours (run-time error) in the two cases during the run. Now you want to call it a typo in the first example or the second, you are free to judge (I did not read his second posting). But here is what I have to say : when you say, p points to a constant area to which a write fails(takes an exception) is not a valid "C" statement (I do that all the time). Although the content of the string is constant, the "abcde\0" is actually a free pointer equivalent to "abcde", a constant string, i.e. a constant pointer to a string of constant letters. Can the letters be changed, yeah sure, any time. Can the address of the string be changed during the run, no, never, but can the pointer p be pointed to another address, yes, sure, again any time (that's what you are doing). Your second example is redundant; the first is good enough.
Read Full Discussion Thread for this article