Data Encryption Program

This is a discussion on Data Encryption Program within the C++ Programming forums, part of the General Programming Boards category; I have two questions on this subject.
1.) How would I (using the file manipulation commands (fstream)), do a search-and-replace ...

You're implementing an encryption algorithm based on substitution isn't it?

Since you know the maximum number of letters and numbers (and perhaps also other reading signs) in the file, you could also create a table before doing anything else.

For example, there are 256 ASCII characters, so you could fill an array of 256 chars with random values. Then read the first character of the file, if this is for example 0xAB, then you could replace this character with element 0xAB of your array. Like this:

current_character = key_array [0xAB];

This way of encoding is faster than searching for characters in a file, since now you have to go through the file only once.