its very simple ..
I guess u are not aware of map data structure.
Basically , when ur getting the character from the file , check it using a map and then the equivalent to that may be printed or stored in a file according to ur wish.
this is the simple code on how to use a map data structure .
map<char,int> mymap;
map<char,int>::iterator it;
mymap['a'] = 0;
mymap['b'] = 1;
mymap['c'] = 2;
mymap['d'] = 3;
mymap['e'] = 4;
mymap['f'] = 5;
do
{
for ( it=mymap.begin() ; it != mymap.end(); it++ )
{
if( s[i] == (*it).first ) // s[i] holds the plain text which is
{ //mapped to the 1st element of map
enc[i++] = (*it).second; // if it matches then the equivalent is
len--; // is stored in ur enc[] which is the
} //encrypted array
}
} while (len != 0);
The above is not the complete code , but gives u fair idea on how to use maps for your encryption.
Also google more on maps for its usage.