On Sun, 2005-01-16 00:18:20 +0100, Gabriel Dos Reis <[EMAIL PROTECTED]>
wrote in message <[EMAIL PROTECTED]>:
> Denis Zaitsev <[EMAIL PROTECTED]> writes:
> 
> | This program:
> | 
> | void x(char *s)
> | {
> |     *s= 'x';
> | }
> | 
> | main()
> | {
> |     x("y");
> | }

> | not <const char*> does nothing in this case.  Should it be considered
> | as a bug?
> 
> In the program? Yes.

Maybe you'd tell him more about the magic :)

char *mytext = "hello";

results in a pointer (which you may later on make pointing to a
different location) that points to a static, read-only string containing
"hello\0". However, if you need to change the text, you need to do it
like this:

char mytext[] = "hello";

Cf. section 6.4.5.6 of the C99 standard.

MfG, JBG

-- 
Jan-Benedict Glaw       [EMAIL PROTECTED]    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 fuer einen Freien Staat voll Freier BÃrger" | im Internet! |   im Irak!   O O 
O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

Attachment: signature.asc
Description: Digital signature

Reply via email to