-
problem with file
what is the problem with this program?
Code:
#include<iostream>
#include<fstream>
using namespace std;
enum flag {no=0,yes=1};
int main()
{
flag setflag=no;
fstream myfile("d:/hsys.dll",ios::binary);
myfile.write((char *)&setflag,sizeof(flag));
if(!myfile)
{
cout<<"operation failed!!\n";
return 0;
}
return 0;
}
-
The mode should be ios::out | ios::binary at least. Since the mode is just a number, if you have to provide a mode, provide the right number, or it won't work.
-
yeah it worked. the program is now running.
but should it have something written inside it. I mean if I open it in note pad. some ascii chars are ought to present in it. But they are not.
-
Since you are printing the number 0 or the number 1, which are non-printing control characters you will not see them in notepad.
Jim
-