PDA

View Full Version : Make a read only text file with C++


dan.s
09-17-2006, 04:25 PM
Hi,
I would like to know how to create a read only text file on the fly using C++.
I have this code:

#include <iostream>
#include <fstream>
using namespace std;
int main(){

ofstream myFile("testfile.txt");
if(myFile.is_open()){
myFile << "Hi!";

myFile.close();
}
cin.get();
return 0;
}

And that generates the text file, but how do i make it readonly?
Thanks,
Dan