public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: hwidjaja@my-deja.com
To: help-gcc@gnu.org
Subject: Re: Segmentation fault
Date: Wed, 17 Nov 1999 16:12:00 -0000	[thread overview]
Message-ID: <80vffq$lrp$1@nnrp1.deja.com> (raw)
In-Reply-To: <80u79j$o86$1@nnrp1.deja.com>

you have to do allocate enough memory of strbuff at insertstring()
function.
do malloc with new size is strlen(strbuff) + strbuff(chrstoins)

hope this help.
In article < 80u79j$o86$1@nnrp1.deja.com >,
  Sarose <sarose@enet.com.np> wrote:
> OS: Redhat Linux 5.2
> GCC: gcc-2.7.2.3-14
>
> Problem:
>
> This is my program using insertstring function
>
> I get Segmentation fault
>
> #include <stdio.h>
> #include <string.h>
>
> char *insertstring (char *strbuf,char *chrstoins,int pos)
> {
> memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
> ((strbuf + pos))+1);
> memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
> return strbuf;
> }
> int main()
> {
> char *buffer;
> char *test="<a href='index.html'>About Enet </a>";
> char *test1="asdflaksdf";
> buffer = insertstring(test,test1,1);
> printf("%s",buffer);
> return 0;
> }
>
> Compiling, Linking & OUTPUT
> # gcc test1.c -o test
> # ./test
> Segmentation fault
>
> I do suspect 'memmove' line of insertstring functions. But HOWTO fix
it
> still getting puzzle??
>
> Hope I will get some help for your side.
>
> --
> Regards,
> npguy
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.

WARNING: multiple messages have this Message-ID
From: hwidjaja@my-deja.com
To: help-gcc@gnu.org
Subject: Re: Segmentation fault
Date: Tue, 30 Nov 1999 23:28:00 -0000	[thread overview]
Message-ID: <80vffq$lrp$1@nnrp1.deja.com> (raw)
Message-ID: <19991130232800.q-R4MOU6aqN5JWE5Er1SgUwciJ5XhSDnE5ngt0u_WXk@z> (raw)
In-Reply-To: <80u79j$o86$1@nnrp1.deja.com>

you have to do allocate enough memory of strbuff at insertstring()
function.
do malloc with new size is strlen(strbuff) + strbuff(chrstoins)

hope this help.
In article < 80u79j$o86$1@nnrp1.deja.com >,
  Sarose <sarose@enet.com.np> wrote:
> OS: Redhat Linux 5.2
> GCC: gcc-2.7.2.3-14
>
> Problem:
>
> This is my program using insertstring function
>
> I get Segmentation fault
>
> #include <stdio.h>
> #include <string.h>
>
> char *insertstring (char *strbuf,char *chrstoins,int pos)
> {
> memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
> ((strbuf + pos))+1);
> memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
> return strbuf;
> }
> int main()
> {
> char *buffer;
> char *test="<a href='index.html'>About Enet </a>";
> char *test1="asdflaksdf";
> buffer = insertstring(test,test1,1);
> printf("%s",buffer);
> return 0;
> }
>
> Compiling, Linking & OUTPUT
> # gcc test1.c -o test
> # ./test
> Segmentation fault
>
> I do suspect 'memmove' line of insertstring functions. But HOWTO fix
it
> still getting puzzle??
>
> Hope I will get some help for your side.
>
> --
> Regards,
> npguy
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.

  reply	other threads:[~1999-11-17 16:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-17  8:30 Sarose
1999-11-17 16:12 ` hwidjaja [this message]
1999-11-18  1:21   ` Sarose
1999-11-30 23:28     ` Sarose
1999-11-30 23:28   ` hwidjaja
1999-11-30 23:28 ` Sarose
2000-05-28  8:45 segmentation fault wert ewrtert
2000-05-28 14:52 ` Martin v. Loewis
2001-09-15 12:51 Segmentation Fault Paulo J. Matos aka PDestroy
2001-09-15 13:18 ` Paulo J. Matos aka PDestroy
2001-09-28 16:33 ` Alexandre Oliva
2002-08-16 23:39 Segmentation fault Lim Jiunn Bin
2005-05-20 23:45 segmentation fault Garritt Page
     [not found] <fc.3b9aca00bfe9273b3b9aca003b27e9bf.44e9e6d@reflex.at>
2005-05-21  3:16 ` Antonio Coralles
     [not found] <20070605114929.9oalrlftyfc0gwkg@webmail1.covadhosting.biz>
2007-06-05 15:53 ` Andrew Haley
2007-06-05 15:56   ` Andrew Haley
2009-07-11  6:55 anandulle
2009-07-11  7:20 Bill McEnaney
2010-03-25 11:45 Segmentation fault beamendsltd
2010-03-25 13:18 ` James Tebneff
2010-03-25 13:58 ` Andrew Haley
2010-03-25 14:33 ` John (Eljay) Love-Jensen

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='80vffq$lrp$1@nnrp1.deja.com' \
    --to=hwidjaja@my-deja.com \
    --cc=help-gcc@gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).