Question: Having trouble writing this small C program: A program written in C (NOT C++) that needs to accept command line arguments (see below) should reverse

Having trouble writing this small C program:

A program written in C (NOT C++) that needs to accept command line arguments (see below) should reverse the order of bytes read, and output the bytes in reverse order. To make this program more manageable, bytes should be processed in blocks of less than 1k characters (block size is a parameter and can be changed by user command line argument). For example, if the block size is 4 and the data is abcdefghijkl, the blocks to be reversed would be abcd, efgh, ijkl, and output should be dcbahgfelkji.

The program should process the following optional command line arguments (user's option - required for program): -i ...for the input file name (default: stdin) -o ...for the output file name (default: stdout) -b ...for the number of characters in a block to reverse (default: 10)

REQUIREMENT: Use only system calls for all input and output operations (write, read, open, close, etc.), including any error messages that may be output (sent to stderr). The data should be from either a file or stdin and the output should be to either a file or stdout.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!