Hello every one.... can you help me out here...
I need to make 2 programms.. on C and other same C++
I need to make a programms that read binary file (like txt file) and produce a hexadecimal dump of that file.
output should look like this (out put should be stored in new txt file)
http://img239.imageshack.us/img239/9...titled1ua6.jpg
Also command line should be used to get the name of data file. and then program will use a lookup table to convert the binary byte to a hex character. Using printf is disallowed.
Here is C programm.... but I have few problems..
First.. how do I open file in C, using console entry?... (I got this workng in C++ but not in C)
This programm just drive me nuts...
Code:
#include <stdio.h>
int main(int argc,char* argv[])
{
FILE* fileHandle;
if (argc != 2)
{
printf("Usage: hexdump <file name>\n");
return -1;
}
fileHandle = fopen(argv[1], "rb");
if (!fileHandle)
{
printf("Error: failed to open file %s for read", argv[1]);
return -1;
}
/* dump data here */
fclose(fileHandle);
return 0;
}
unsigned char lower(unsigned char c)
{
unsigned char one_byte;
one_byte = c & 0x0F;
return one_byte;
}
unsigned char upper(unsigned char c)
{
unsigned char one_byte;
one_byte = (c & 0xF0) >> 4;
return one_byte;
}