This is the mail archive of the
mailing list for the GCC project.
RE: Problem with the string
- From: "John \(Eljay\) Love-Jensen" <eljay at adobe dot com>
- To: "kanishk rastogi" <kanishk dot 85 at gmail dot com>, "Andrew Haley" <aph at redhat dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 24 Nov 2006 10:40:41 -0800
- Subject: RE: Problem with the string
- References: <firstname.lastname@example.org>
> i want to put string "kanishk" into writeable memory (or other than read execute segment). Is there a way for doing this without making any change in calling sequence (for example it may be regulated by some switch in gcc) or there is no provision in C99 standard for it.
The 'string "kanishk"' is a read-only non-modifiable C-string literal constant.
Are you programming in C or C++? Then a read-only non-modifiable C-string literal constant is read-only and non-modifiable. There is no provision in C or C++ to make a read-only non-modifiable C-string literal constant into a non-read-only modifiable C-string literal mutable.
If you want a modifiable string, you have to declare it that way, for example:
char kanishk = "kanishk";
(Hopefully the MyFuncThatModifiesTheCharPtrData doesn't overrun the buffer.)