how to deal between txt files

first,I want to open an eixst file 1.txt.
this file contain hexadecimals.such as "03451b435e...".
I want to get the 20th 21th 22th 23th number in every line in the file.
this four char combin 2 hexa numbers. I want to change these 2 hexa number into 1 decimal number (such as 2300.)and at last replace the 4 characters from 20th.

second.T need to open anther file 2.txt.

in this file it contain in every line a decimal number and a string which follow the decimal number and describe the meaning.such as "2300 init code"
and then I want to replace the changed decimal in the 1.txt with the same number in 2.txt file.but replace with the string "init code".

can anybody give a clue or code?
This is a topic I had trouble with for a while. I found the following link really helpful:

http://cplusplus.com/doc/tutorial/files/

Try reading that over and experiment with the examples they give.
Topic archived. No new replies allowed.