Skip to content

Instantly share code, notes, and snippets.

@challapradyumna
Created March 1, 2013 11:26
Show Gist options
  • Save challapradyumna/5064053 to your computer and use it in GitHub Desktop.
Save challapradyumna/5064053 to your computer and use it in GitHub Desktop.
int main()
{
char m[100],g[20],t[100],z[100];
int i,start=0,end,fl,gl,j,rl,a,b,k;
printf("Enter the string of bits");
scanf("%s",&m);
printf("Enter the generator");
scanf("%s",&g);
fl=strlen(m);
gl=strlen(g);
printf("%d\n",fl-gl+1);
for(i=0;i<gl;i++)
{
t[i] = m[i];
}
for(i=0;i<fl-gl+1;i++)
{
//intf("%d\n",i);
for(j=0;j<gl;j++)
{
a=g[j];
b=t[start+j];
if((a == '0' && b == '0' ) ||(a =='1' && b== '1'))
{ t[j] = '0'; }
else{ t[j] = '1'; }
printf("%c",t[j]);
}
for(k=0;k<gl;k++)
{
t[k] = t[k+1];
}
t[gl-1] = m[gl];
printf("\n");
start++;
// t[start+gl+1] = m[start+gl+1];
}
rl = strlen(t);
for(i=0;i<rl;i++)
{
printf("%c",t[i]);
}
return 0;
}
11010110110000
10011
01110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment