From: Krishna Mohan <gkmohan@rocsys.com>
To: Progga <abulfazl@juniv.edu>
Cc: LinuxC <linux-c-programming@vger.kernel.org>
Subject: Re: pointer initialization of string constant
Date: 23 Jan 2005 19:06:17 +0530 [thread overview]
Message-ID: <1106487378.1122.14.camel@KrishnaMohan> (raw)
In-Reply-To: <20050123184550.B330@Imrashi.net.bd>
Dear progga
U are right. But my doubt is : when i run gdb and execute p ptr either
just after or before printf, pbc has been displayed. I'm getting
segmentation fault only at the end, it seems, because when i run
./a.out "pbc is not displayed" but prompted segmentation fault error.
why is it so? How does segmentation fault raises, though
pointer-pointing contents has been changed & even displayed using gdb. i
am interested to know the internals.
Thanq for ur interest.
Regards
Krishna Mohan
On Sun, 2005-01-23 at 18:15, Progga wrote:
On Sun, Jan 23, 2005 at 11:56:11AM +0530, Krishna Mohan wrote:
>
> main()
> {
> char *ptr = "abc";
> ptr[0] = 'p';
Since ptr points to read-only mem, changing ptr[0] does not seem to be a very
wise idea.
next prev parent reply other threads:[~2005-01-23 13:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-23 6:26 pointer initialization of string constant Krishna Mohan
2005-01-23 12:45 ` Progga
2005-01-23 13:36 ` Krishna Mohan [this message]
2005-01-24 5:49 ` how to implement tail -n Venkatesh Joshi
2005-01-24 6:30 ` Eric Bambach
2005-01-25 14:10 ` Robert Lorentz
2005-01-24 19:26 ` Glynn Clements
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=1106487378.1122.14.camel@KrishnaMohan \
--to=gkmohan@rocsys.com \
--cc=abulfazl@juniv.edu \
--cc=linux-c-programming@vger.kernel.org \
/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 NNTP newsgroup(s).