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

Re: C program segfaults when run, not under GDB



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