RE: Problem with the string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi kanishk,

> 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";
MyFuncThatModifiesTheCharPtrData(kanishk);

(Hopefully the MyFuncThatModifiesTheCharPtrData doesn't overrun the buffer.)

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux