Ask Question, Ask an Expert


Ask C/C++ Expert

Home >> C/C++

problem 1) prepare the program which compute the CRC-16 value for a given file and also verifies the correctness of a given file that already has CRC-16 value appended at the end, as more fully described below.

Use the CRC polynomial x^(16) + x^(11) + x^(8) + x^(7) + x^(3) + x^(2) + 1.

Program operation:

1) The program should compile from the command line.

2) The program executable file name must be “crcfile”.

3) The program should run from the command line and take two (2) command line parameters.

4) The first command line parameter would be a flag value which identifies the mode of operation: “c” for calculating a CRC value, or “v” for verifying a CRC value. Only these two values are allowed. Any other values must produce a simple error message and a graceful exit from the program.

5) The second command line parameter would be the name of the file to be examined. The file must be a text file that is in the same folder as the program executable. If the file is not found, the program must issue a simple error message and exit gracefully.

6) The program must direct all output to the command window (terminal) screen. The details of what to output are describeed below.
Specific Functions inside code:

You should implement the following functions/methods:

• A function/method for converting a hexadecimal string into binary string

• A function/method for converting a binary string to hexadecimal

• A function/method to validate the characters in the input file

• An XOR function/method that takes as input two binary strings and returns the XOR result.

• A function/method for CRC calculation

• A function/method for CRC verification

Input file format:

Create YOUR OWN VALID input file.

Valid input files would be text files which contain only hexadecimal characters. Either upper or lower case letters may appear, but they would only be letters which correspond to hexadecimal characters. There would be no whitespace, punctuation, or special characters in the input files.

You should check for input correctness by implementing code to verify that each character in the input file is a valid hexadecimal character (0,1,2,3,4,5,6,7,8,9A,B,C,D,E,F,a,b,c,d,e,f). Valid upper and lower case hex letters will be given the same meaning (“a” = “A” = 1010, etc.)
If an input file contains any invalid characters (other than an end-¬?of-¬?file marker), then the program should issue an appropriate brief error message and terminate gracefully.

Output format:

Print out the hexadecimal file that is read, 80 hex characters to a line.

Next, you should convert the hexadecimal file into binary. Recall that one hex character is four bits. Read the input file and form a binary string. The length of the binary string will be four times the length of the input file because each hexadecimal character will be replaced by 4 binary bits. You will have to define a separate function to get the binary equivalent of a hexadecimal character.

You must state how many zeroes are appended to the input. You must then print the binary version of the input file (after appending) 64 binary bits per line. You must also insert a space after every four binary bits that you print (increasing the line length to 80 characters).

Next, you will show the result of each XOR operation involved in the CRC calculation or verification. The result value at each step is a binary value that contains all of the digits of the dividend after an XOR operation.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M94600

Have any Question? 

Related Questions in C/C++

Write a program that calculates mileage reimbursement for a

Write a program that calculates mileage reimbursement for a salesperson at a rate of $0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer re ...

Discussion questionsplease respond to all of the following

Discussion Questions Please respond to all of the following prompts: • What is a friend function and how is it declared? • Which operators cannot be overloaded and why? • What is a macro in C++ programming and what are s ...

Assignment simple 5-card poker gamein this assignment you

Assignment: Simple 5-Card Poker Game In this assignment, you will develop a simple poker game, complete with basic AI, using the object oriented programming principles discussed in class. Flow of Play Your poker game's p ...

Write an application that allows the user to enter two

Write an application that allows the user to enter two variables: number (real) and code (character). Calculate the value indicated by the table below: If code is Result A symbol the whole part of the number everything e ...

Programming assignment- in this assignment you are

Programming Assignment- In this assignment you are requested to write a C++ program that displays the following colored pyramid on the screen: - The pyramid is 71 characters wide and 21 characters high. - To draw it, you ...

Question 1you are facing the following problem you are

Question 1 You are facing the following problem: You are given a robot and your task is to "guide" the robot through a 2-dimensional maze such that the robot can reach a desired goal state. Assume that the maze is define ...

Fix a programthe program is already done and it runs welli

Fix a program The program is already done and it runs well.. I just need someone to fix it for me, the problem happens when you insert invalid day or invalid ticket type, I want you to end the program *at that point* as ...

Please use codeblockslist the program and the output on the

Please use codeblocks List the program and the output on the command line Eg #include #include using namespace std; int main() { floatjohno = 0.5; size_t size = 24; vector array(size); for(inti=0; i     { johno = johno + ...

1 learner objectivesat the conclusion of this programming

1. Learner Objectives: At the conclusion of this programming assignment, participants should be able to: * Apply repetition structures within an algorithm * Construct while (), for (), or do-while () loops in C * Compose ...

1 write a program to find the sum amp average of the given

1) Write a program to find the sum & average of the given numbers using the while loop. 2) Write a program in C to find the sum and average of the given numbers stored in an array of n values.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate