Write a C program which will display the contents of a file in base-16 (hexadecimal) and in ASCII.
Complete the following tasks:
Some useful hints:
Requirements:
Sample Output (user input is in bold)
hexdump -C yyy.bin
00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
|.ELF............|
00000010 03 00 03 00 01 00 00 00 f7 32 00 00 34 00 00 00
|.........2..4...|
00000020 94 51 02 00 00 00 00 00
Given below is the code for the question. Please do rate the answer if it helped. Thank you.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
FILE *fp;
char data[16];
int count, i;
int offset = 0;
if(argc != 2){
printf("Usage: %s
<filename>\n", argv[0]);
return 1;
}
fp = fopen(argv[1], "rb");
if(fp == NULL){
printf("ERROR: could not open file
%s for reading\n", argv[1]);
return 1;
}
count = fread(data, sizeof(char), 16 * sizeof(char),
fp);
while(count != 0){
printf("%08x", offset);
//print the hex values of
bytes
for(i = 0; i < count; i++)
printf(" %02x",
data[i]);
//print spaces if count is less
than 16 ... to align with printable characters
for(i = count; i < 16;
i++)
printf(" %2c", '
');
printf(" ");
//print the printable
character
for(i = 0 ;i < count;
i++){
if(isprint(data[i]))
printf("%c", data[i]);
else
printf(".");
}
offset += count;
printf("\n");
count = fread(data, sizeof(char),
16 * sizeof(char), fp);
}
fclose(fp);
return 0;
}

Write a C program which will display the contents of a file in base-16 (hexadecimal) and...
Please read this comment:
This is the only file given by my professor and so can
you please help me to write a python program. You can use any test
file and post the output with the code. The output might be
different then above but please help me to get started with the
PYTHON code. Thank you in advance
You are going to write a Python program that represents a command line version of a hexadecimal editor. This program...
The program is done in C. This program opens a file containing binary or text and reads every byte in the file and writes both the ASCII hex value for that byte as well as it’s printable (human-readable) character (characters, digits, symbols) to standard output. The issue I am having is when the file has multiple lines being read. The first line is read and done properly but the other lines do not work correctly. For instance, the text file...
Write a C++ program that will read in image data from the file "image.txt" and illustrate that image as ASCII art. The Image file will contain several lines, representing horizontal rows in the image, and each line will have several integers in the range 0-255. representing povels, separated by spaces. You should read this image data into a vector vector in Once you've read in the phel data, go through the image and print out each piel in the image...
Write a program that implements an elementary bit stream cipher. An elementary level bit stream cipher is an encryption algorithm that encrypts 1 byte of plain text at a time. This one uses a given 4-bit bit pattern as the key. The size of the encrypted message that we want to be able to send has a maximum length of 200 characters. You must: 1. prompt the user to input the clear text to be encrypted. You must use printf()...
Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...
Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple program. Generally, it reads a file as specified by the user and prints its contents. A typical usage is as follows, in which the user wants to see the contents of my-cat.c, and thus types: prompt> ./my-cat my-cat.c #include <stdio.h> ... As shown, my-cat reads the file my-cat.c and prints out its contents. The "./" before the my-cat above is a UNIX thing; it...
File structure is a structure, which is according to a required format that operating system can understand. A file has a certain defined structure according to its type. A text file is a sequence of characters organized into lines. A source file is a sequence of procedures and functions. An object file is a sequence of bytes organized into blocks that are understandable by the machine. When operating system defines different file structures, it also contains the code to support...
Hi, I need help writing a program that reads in data (hex, octal or decimal values) from an input file and outputs the values in to another base form (hex, octal,decimal) one line at a time depending on the formatting characters provided by the input file. I am posting the code requirements below and an example of what theinput file will look like and what should be output by the program. I only need the one .cpp program file. Thanks...
Write a C program to run on ocelot to read a text file and print it to the display. It should optionally find the count of the number of words in the file, and/or find the number of occurrences of a substring, and/or take all the words in the string and sort them lexicographically (ASCII order). You must use getopt to parse the command line. There is no user input while this program is running. Usage: mywords [-cs] [-f substring]...
C programming lab: Description: In this lab you will write a program that will contain two functions, setlsbs() and getlsbs(). These functions will use bitwise operators to embed and extract "hidden" bits in a character array. Write a program to test your functions as follows: Obtain a random number seed from the command line of your program using command line arguments. Initialize an array p of 8 unsigned char with random numbers from 0 to 255 Initialize a separate unsigned...