Question
For this lab, you are required to create a C program which works with command line arguments. Write a C program to accept two filenames
For this lab, you are required to create a C program which works with command line arguments. Write a C program to accept two filenames from the command line. The first filename should be a source filename and "should" already exist on disk. The second filename will be the output file you program should create/overwrite. To make this utility more universal, your code must treat the input file as if it were a binary file. That means that you are constrained to use open(), read() and write() as file access primitives. If you use the fopen() series of calls, your code will not produce the desired effect and will be graded accordingly. Your code should allow for a fairly long filename as someone might want to include a path to the file. You should assume up to 512 characters for each filename. Your code should then:
- Read in the original filename provided through the command line and copy its content to the output file in such a way that the content of the output file is in the reverse byte order of the input file. By this I mean that if the input file contains the characters "its a small small world", the output file would contain "dlrow llams llams a sti".
- Of course, there should be no limitations on the size of the file. This means that the use of arrays for storing the content of the file would not be appropriate. HINT: lseek(). - Arrays and the use of malloc() or equivalent system calls are not permitted.
- You should then run the reversed file back through the same program creating a third file. The 3rd file can then be compared to the original input file using either the diff command or by calculating MD5 sums for both.
- md5sum is the command to use. It is followed by the filename to be analyzed
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