public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "John \(Eljay\) Love-Jensen" <eljay@adobe.com>
To: "kanishk rastogi" <kanishk.85@gmail.com>,
	"Andrew Haley" <aph@redhat.com>
Cc: <gcc-help@gcc.gnu.org>
Subject: RE: Problem with the string
Date: Fri, 24 Nov 2006 18:45:00 -0000	[thread overview]
Message-ID: <EDC8DDD212FEB34C884CBB0EE8EC2D91216644@namailgen.corp.adobe.com> (raw)
In-Reply-To: <9ee2fe770611240316p30920d39nb1d28dde53936ea0@mail.gmail.com>

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

  parent reply	other threads:[~2006-11-24 18:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-24  9:26 kanishk rastogi
2006-11-24  9:56 ` Andrew Haley
2006-11-24 10:15   ` kanishk rastogi
2006-11-24 10:18     ` Andrew Haley
2006-11-24 10:21       ` kanishk rastogi
2006-11-24 10:24         ` Andrew Haley
2006-11-24 10:31           ` kanishk rastogi
2006-11-24 10:37             ` Andrew Haley
2006-11-24 11:16               ` kanishk rastogi
2006-11-24 11:31                 ` Andrew Haley
2006-11-24 11:40                   ` kanishk rastogi
2006-11-24 13:33                     ` Andrew Haley
2006-11-24 15:31                       ` Segher Boessenkool
2006-11-24 18:45                 ` John (Eljay) Love-Jensen [this message]
2006-11-28  2:57 ` Michael Eager

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EDC8DDD212FEB34C884CBB0EE8EC2D91216644@namailgen.corp.adobe.com \
    --to=eljay@adobe.com \
    --cc=aph@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=kanishk.85@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).