Convert file to hex for c

broken image
broken image
broken image

I tried googling to see if others were trying to do the same thing, but people were either already reading from a binary file or already had hexadecimal values in the file. How can I structure this program so that it reads the hexadecimal values of a standard text file and either (a) puts them in an array (which I think should be simple enough with a for loop) or (b) prints them out to the screen? However, the problem is that even though I'm in 'read binary' mode, it won't give me the hexadecimal values of the text file. Printf('The contents of %s file are :\n', file_name) Īs you can see this is really just a simple file in, read and print contents. Perror('Error while opening the file.\n') Printf('Enter the name of file you wish to see\n') įp = fopen(file_name,'rb') // read binary mode txt file and not a binary file) and store it in an array for later.

broken image

For example, say I had the text file 'helloworld.txt' that simply had the words 'Hello World!' in it, I want to specify to the program to take that file, read its hexidecimal values (again the file is a simple. I want to take in a file and view its hexadecimal values. I am writing a c program that functions much like a hex editor.

broken image