trouble in getting this crc coding right
hi i am stuck with doing crc coding for c programming
i ask for user to define the divisor and dataword
and got the augemented dataword
but have trouble in divinding the augemented dataword with the divisor and getting the remainder result.i am stuck with the algo there
here's my coding
Code:
#include <stdio.h>
#include<stdlib.h>
#include <conio.h>
int main()
{
int a[20],b[20],c[20],i,k,j,n,s=0,t=0;
printf ( "Welcome to the CRC Encoder/Decoder!\n");
printf ( "press n to exit at anytimes\n");
/* do{*/
printf("enter size of dataword\n");
scanf("%d",&n);
printf("enter dataword to be transfer bit by bit\n");
for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("your input dataword is\n");
for (i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
printf("enter size of divisor\n");
scanf("%d",&k);
printf("enter divisor to be transfer bit by bit\n");
for (j=0;j<k;j++)
{
scanf("%d",&b[j]);
}
printf("your input divisor is\n");
for (j=0;j<k;j++)
{
printf("%d\n",b[j]);
}
for (i=0;i<(k-1);i++)
{
a[n+i]=0;
}
printf("the augmented dataword\n");
for (i=0;i<(k+n-1);i++)
{
printf("%d\n",a[i]);
}
/*i guess this is wrong but i tried to get the remainder by using modulo 2 like ( a ^ b )*/
for (i=0;i<k;i++)
{
c[i]=a[i];
}
for (t=0;t<(n-1);t++)
{
for (j=1;j<k;j++)
{
c[j-1]=c[j]^b[j];
c[j]=a[k+s];
return 0;
}