-
Win API file problem
The following section of code is in my encryption programme that I am developing.
If the file doesn't exist, there is no problem with writing the character string to the file.
However, if I am overwriting the file, I cannot write the character string to the file. Just a blank file is produced.
ofstream CiphertextF;
CiphertextF.open(cipherfilename, ios::out|ios::noreplace);
if(!CiphertextF.is_open())
{
if(MessageBox(hwnd, "File Already Exists, Overwrite?","warning", MB_YESNO|MB_ICONQUESTION)==IDYES)
CiphertextF.open(cipherfilename, ios::out | ios::trunc);
else
break;
}
....more code that is exectuted whether or not the file exists,
....including create ciphertext
....
....
Ciphertextf<<ciphertextstring<<endl;
any help would be much appreciated.
Thanks,
Donal
-
Somebody must have an idea of what I am doing wrong???
thanks,
Donal