Search
 
SCRIPT & CODE EXAMPLE
 

C

implement crc using c language

#include <stdio.h> #include <conio.h> #include <string.h> void main() {	int i,j,keylen,msglen;	char input[100], key[30],temp[30],quot[100],rem[30],key1[30];	clrscr();	printf("Enter Data: ");	gets(input);	printf("Enter Key: ");	gets(key);	keylen=strlen(key);	msglen=strlen(input);	strcpy(key1,key);	for (i=0;i<keylen-1;i++) {		input[msglen+i]='0';	}	for (i=0;i<keylen;i++)	 temp[i]=input[i];	for (i=0;i<msglen;i++) {		quot[i]=temp[0];		if(quot[i]=='0')		 for (j=0;j<keylen;j++)		 key[j]='0'; else		 for (j=0;j<keylen;j++)		 key[j]=key1[j];		for (j=keylen-1;j>0;j--) {			if(temp[j]==key[j])			 rem[j-1]='0'; else			 rem[j-1]='1';		}		rem[keylen-1]=input[i+keylen];		strcpy(temp,rem);	}	strcpy(rem,temp);	printf("
Quotient is ");	for (i=0;i<msglen;i++)	 printf("%c",quot[i]);	printf("
Remainder is ");	for (i=0;i<keylen-1;i++)	 printf("%c",rem[i]);	printf("
Final data is: ");	for (i=0;i<msglen;i++)	 printf("%c",input[i]);	for (i=0;i<keylen-1;i++)	 printf("%c",rem[i]);	getch();}
Comment

PREVIOUS NEXT
Code Example
C :: choose random number with weight 
C :: argparse allow line break 
C :: sizeof file c 
C :: getchar c 
C :: c assignment operators 
C :: -42 c to f 
C :: c list 
C :: strstr 
C :: threads in c 
C :: c file struct 
C :: C special character display 
C :: C float and double Output 
C :: c programming programiz 
C :: linear and binary search 
C :: insse suprafata arabila pe ani 
C :: git add -u flag 
C :: count number of items using delimiter 
C :: how to do Employing defensive code in the UI to ensure that the current frame is the most top level window 
C :: anthracnose pronounce 
C :: solidity signature r s v 
C :: error: invalid type for iteration variable ‘i’ #pragma omp parallel for 
C :: arma 3 key pressed 
C :: fraction sum c 
C :: reverse binary tree c 
C :: adding three numbers in c 
C :: manasa loves maths solution IN C 
C :: search and then change string -- strstr and strcpy 
C :: payement des véhicules a la sortie de station de langue c 
C :: countoddevenDifference 
C :: linked list in c 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =