Write a C program that takes a single command-line argument and produces the same output as the xxd program with the same argument. You must include meaningful comments on your code.
Write a C program that takes a single command-line argument and produces the same output as the xxd program with the same argument. You must include meaningful comments on your code.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question

Transcribed Image Text:Problem:
Write a C program that takes a single command-line argument and produces the same
output as the xxd program with the same argument. You must include meaningful
comments on your code.
A sample test would look like this:
$ ./project1 some_filename
and would produce the same output as this:
$ xxd some_filename
Note that the C function isprint(3) could prove quite useful here.
To test the project, it will be run like this:
$./project1 filename ## I may do this for multiple filenames
Submission Instruction:
1. Go to the directory containing your Projec1.c file. Upload or create "test.txt" file in
the same directory. At the Linux $ prompt, type in Is (for list) to make sure the
Project1.c file is listed in this directory. Issue the following commands at the prompt
to create a script file to be submitted with the project1.c file.
• $ script project1.txt
• $pwd
• $ ls -1
• $ cat-n project1.c
• $ gcc project1.c -o project1
• $ xxd test.txt
• $ ./projectl test.txt
• $ exit
•$ wkhtmltopdf project1.txt project1_log.pdf
2. Upload the following files in D2L->Assessment->Dropbox-> Projectl
(Please do not zip them)
a. projectl.c
b. projectl_log.pdf

Transcribed Image Text:Introduction to Computer Systems
Project 1
Due: February 09, 2023 by 5:00 PM
Spring 2023
Introduction:
xxd command in Linux creates a hex dump of a given file or standard input. It's simple.
For example, suppose you have a text file 'test.txt' with contents as shown below:
The isprint() function checks whether a character is a printable character or not.
Check more information in:
https://www.programiz.com/c-programming/library-function/ctype.h/isprint
Here's how you can use xxd to convert the file contents into hex:
$ xxd test.txt
And here's the output:
00000000: 5468 6520 6973 7072 696e 7428 2920 6675
00000010: 6e63 7469 6f6e 2063 6865 636b 7320 7768
00000020: 6574 6865 7220 6120 6368 6172 6163 7465
00000030: 7220 6973 2061 2070 7269 6e74 6162 6c65
00000040: 2063 6861 7261 6374 6572 206f 7220 6e6f
00000050: 742e 0a43 6865 636b 206d 6f72 6520 696e
00000060: 666f 726d 6174 696f 6e20 696e 3a20 6874
00000070: 7470 733a 2f2f 7777 772e 7072 6f67 7261
00000080: 6d69 7a2e 636f 6d2f 632d 7072 6f67 7261
00000090: 6d6d 696e 672f 6c69 6272 6172 792d 6675
000000a0: 6e63 7469 6f6e 2f63 7479 7065 2e68 2f69
000000b0: 7370 7269 6e74 0a
The isprint() fu
nction checks wh
ether a characte
r is a printable
character or no
t..Check more in
formation in: ht
tps://www.progra
miz.com/c-progra
mming/library-fu
nction/ctype.h/i
sprint.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education