-
file minpulation
hi everybody
i am looking for a way to modify FILE (binary/HEX) representation.
what i mean is :
when you write an 'a' into a file
then open the same file using any hexEditors
then you will find number 61 Hex which is equal to 97 Dec
and both are the number that equal to 'a' in the ASCII table
-******************************-
so what i need to write 'a'
is to write 61 Hex to a file
and this what i want to do using c++
thanks
-
What have you done so far?
--
Mats
-
nothing to be mentioned
with the normal <iostream>
i can not do anything more.
-
To the computer, numbers and characters aren't any different, nor are hexadecimal and decimal. In the end, it comes down to numbers stored in memory in binary form, and everything else is a matter of interpretation.
Write an 'a' to a file or write the number 97, there's no difference. The difference appears only when you use a text editor or a hex editor to open the file.
-
silly me
so the question will be changed
*************
how could i write one of the special characters to my file ?
since i do not know how to write them using my keyboard
-
You can write anything to a file as long as you can represent it numerically - although you will need to specify:
The whole line may look something like this:
Code:
ofstream myfile ("example.bin", ios::out | ios::app | ios::binary);
as a flag when you open the file if you don't want the certain combinations to be "changed", (such as if you open a file on Windows, it adds a '\r' when you output a '\n').
More info here:
http://www.cplusplus.com/doc/tutorial/files.html
--
Mats
-