Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

C++ Code

By: a guest on Jan 21st, 2013  |  syntax: C++  |  size: 0.96 KB  |  views: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include "fileIO.h"
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     ifstream myRead;
  10.     ofstream myWrite;
  11.     int error;
  12.     error = open("test.txt", myRead, myWrite);
  13.     if(error == 0) {
  14.         cout<<"Sucessfully opened files!";
  15.     }
  16.     else if(error == 1) {
  17.         cout<<"Could not open file for writting.";
  18.     }
  19.     else if(error == 2) {
  20.         cout<<"Could not open file for reading.";
  21.     }
  22.     else if(error == 3) {
  23.         cout<<"Could not open files for reading or writting.";
  24.     }
  25.     else cout<<"Some other error occured.";
  26.     bool torf;
  27.     string message;
  28.     message = "This_is_a_test";
  29.     torf = write(myWrite, message);
  30.     if(torf) {
  31.         cout<<"Sucessfully wrote data.";
  32.     }
  33.     else if(!torf) {
  34.         cout<<"Message could not be outputted.";
  35.     }
  36.     else cout<<"There was some other error.";
  37.     string line;
  38.     line = read(myRead);
  39.     cout<<line;
  40. }