Question
C Program help I am trying to complete a C program that does C R C calculation . I got everyting to work except a
C Program help I am trying to complete a C program that does C R C calculation . I got everyting to work except a function to display binary difference at each X O R step .
the program compiles using two comand line arguments .
programName c [input Hex] : for calculation
programName v [input Hex] : for virification
The polynomial is always the same
here is how the output should look like :
Here is my code so far :
#include
//HEX-BINARY void HEXA_BIN(char *hexaDecimal) { long int i=0; char block[5]; while(hexaDecimal[i]) { switch(hexaDecimal[i]) { case '0': strcpy(block, "0000"); break; case '1': strcpy(block, "0001"); break; case '2': strcpy(block, "0010"); break; case '3': strcpy(block, "0011"); break; case '4': strcpy(block, "0100"); break; case '5': strcpy(block, "0101"); break; case '6': strcpy(block, "0110"); break; case '7': strcpy(block, "0111"); break; case '8': strcpy(block, "1000"); break; case '9': strcpy(block, "1001"); break; case 'a': strcpy(block, "1010"); break; case 'b': strcpy(block, "1011"); break; case 'c': strcpy(block, "1100"); break; case 'd': strcpy(block, "1101"); break; case 'e': strcpy(block, "1110"); break; case 'f': strcpy(block, "1111"); break; } i++; strcat(binary_string, block); } } void CrcChecker() { int i,p; int c; for(i=0; i //BINARY-HEX void BIN_HEXA(char *binary) { long int dec; long int rm; long int qt; int i=1,j,temp; char hx[50000]; dec = strtol (binary,NULL,2); qt = dec; while(qt!=0) { temp = qt % 16; if( temp 0; j--) printf("%c",hx[j]); printf(" (hex)"); } //MAIN int main(int argc, char *argv[]) { int i=0,e=0; int i_line=0; polynomial="1101"; polynomial="1100110110101"; int spacer=0; strcpy(input, argv[2]); printf("----------------------------------------------------------------------- "); //CHOOSE CALC MODE if (strcmp(argv[1], "c") == 0) { printf("The input string (hex): %s ", input); for(i = 0; i for(i=0; i //CHOOSE VERIFY MODE else if (strcmp(argv[1], "v") == 0) { printf("The input string (hex): %s ", input); for(i = 0; i length = strlen(binary_string); for(i=strlen(binary_string) - 12; i printf("The binary string difference after each XOR step of the CRC calculation: "); i_line=0; if (strlen(chksm) % 4 == 0) { printf("The CRC computed for the input : "); for(i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started