Re: Segmentation Problem

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

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux