Segmentation Problem

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

 



Hi,

Recently I wrote a small program for bit stuffing i.e., I give an input
of stream of bits(0,1) and if there are five consecutive 0's then I
append a bit 1 and vice versa.

It compiled well, but on executing it, there was an SEGMENTATION ERROR.
Can anyone please help me in solving the problem.
Below is the code I wrote for that program ....

#include<stdio.h>
#include<string.h>
int main()
{
 char *s="",t;
 int i,j,l,c=0;
 printf("\n Enter String to be Bit Stuffed : ");
 scanf("%s",s);
 t=s[0];
 l=strlen(s);
 for(i=1;s[i]!='\0';i++)
 {
	if(t==s[i])
	{
		c++;
		if(c==4)
		{
			for(j=l;j>l;j--)
				s[j+1]=s[j];
			if(s[i]=='0')
				s[i+1]='1';
			else
				s[i+1]='0';
			printf("\n String after Bit Stuffing is %s",s);
		}
	else
		continue;
	}
 else
 {
	t=s[i];
	c=0;
	continue;
}
}
return 1;
}
		
Regards,
kolpur


[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