i found this example. It creates a file which has the
sample string in it with a simple masking operation
performed on the data first. Then it reads it back
and unmasks it so it can restore the original contents.

i would like help to convert it so it reads through each character in the text and converts it, instead of creating the string in the code and converting it. i just dont know where to start. can you give me some pointers please.

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;

char mask(char ch)
{
return ch = ~ch;
}

int _tmain(int argc, _TCHAR* argv[])
{
string str("text to change.\n1234567890\n");
ofstream ofs("testdata.txt",ios::binary);
if(!ofs)
{
cout << "Can't open output file!\n";
return -1;
}
string str2;
str2.resize(str.size());
transform(str.begin(), str.end(), str2.begin(), mask);
ofs << str2; // add error checks
ofs.close();
ifstream ifs("testdata.txt",ios::binary);
if(!ifs)
{
cout << "Can't open input file!\n";
return -1;
}
str.clear();
ifs >> str; // add error checks
// cout << str << endl;
str2.clear();
str2.resize(str.size());
transform(str.begin(), str.end(), str2.begin(), mask);
cout << str2 << endl;

return 0;
}