Segmentation Problem
John Love-Jensen
eljay@adobe.com
Mon Sep 15 18:27:00 GMT 2008
Hi kolpur,
> Can anyone please help me in solving the problem.
Yes, see below.
> char *s="",t;
Here you have allocated one byte of memory for s.
You may be better off specifying:
char t;
char s[1024];
That way, the buffer s points to is on the stack, and the buffer can
accommodate more input, and the buffer does not reside in what could
possibly be read-only memory.
> int i,j,l,c=0;
> printf("\n Enter String to be Bit Stuffed : ");
> scanf("%s",s);
Here you are scanning into s. The s buffer is only one byte long.
Depending on your compiler settings, the s buffer may be read-only (or maybe
not... my C is rusty, and perhaps I'm referring to a C++ -ism). You have
not taken any precautions to insure that the scanf does not overflow the
buffer (out of bounds error, which could result in a SEGV).
HTH,
--Eljay
More information about the Gcc-help
mailing list