I am to open a text file, copy it, increment its ASCI characters by ten and then write it into a created text file. This is the code that I have so far.(visual c++ 6.0). The problem is that I cannot increment the characters. It gives me and overwrites my original file with ÌÌ characters.
int main(){
const int size=30;
char filename[size];
cout<<"Enter the file name that you will like to encrypt: \n";
cin.getline(filename, 30);
fstream dataFile;
dataFile.open(filename,ios::out|ios::binary);
if (!dataFile){
cout<<"could not open.. exitting\n";
exit (1);
}
char list[size];
dataFile.write(reinterpret_cast<char *>(&list),size);
if(dataFile.fail()){
cout<<"failed to write..exitting";
exit (1);
}
dataFile.close();
char filename2[size];
cout<<"Enter the file name that you will like to create: \n";
cin.getline(filename2, 30);
for (int i=0; i<size; i++){
list[i]+= 10;
}
ofstream outFile(filename2);
outFile.write(reinterpret_cast<char *>(&list), size);
outFile.close();
return 0;
}