[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C program segfaults when run, not under GDB
- To: milesteg(at-nospam)surfree.net.il, Eugene Romm <sf_milesteg(at-nospam)bezeqint.net>, linux-il(at-nospam)linux.org.il
- Subject: Re: C program segfaults when run, not under GDB
- From: Vlad <svladek(at-nospam)netvision.net.il>
- Date: Sun, 25 Nov 2001 12:39:05 +0200
- Delivered-To: linux.org.il-linux-il@linux.org.il
- In-reply-to: <3C00BBB9.4060905@bezeqint.net>
- References: <3C00BBB9.4060905@bezeqint.net>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
Try to learn about pointers and function calls in C
it's basic error : when you try to pass to function string not in variable
like char* or char[] and try to modify it
error-->"squeezechar2("abcdeFghijklmnopqrstuvwxyZ","deF");"
solution is to define string that you will modify in function like this :
char string[]= "abcdeFghijklmnopqrstuvwxyZ";
correct-->"squeezechar2(string,"deF");"
On 25 November 2001 11:36, Eugene Romm wrote:
> Hello.
>
> I've written a procedure that's supposed to remove all occurances of
> string2 from string1 (parameters).
> For reasons I do not understand, the program compiles but segfaults when
> run from the command prompt, but silently executes without a warning
> when run under GDB. Attached is the program. Segfault occurs on line 29,
> as far as I can tell.
--
=========================================
Vladek Sobolevsky (Lingvo)
* Black Holes it's where God divided by zero*
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il