
Originally Posted by
The Invisible Man
Crap, I meant C++. Sorry, but... um.... yeeeeeeeeeeeeaaaaaaaaaaah. Could I get that the Open File command on C++? Command for the Standard Library?
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
fstream FILE("foo.txt",ios_base::trunc); //First, we open a file named "foo.txt", overwriting any existing data. (signified by ios_base::trunc for truncate ;))
if(!FILE.is_open();){ //If the file opens, then continue
FILE<<"Stuff to write\n"; //Write to the File stream using the insertion operators <<
string In;
FILE>>In; //Read from the stream using the extraction operators >>
}
return EXIT_SUCCESS; //Because macros are just way cooler than constants
}
Bookmarks