Advertisement
Guest User

TekSyndicateC++CodeHelp001

a guest
Aug 14th, 2013
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main(){
  7.  
  8.      char filename[200];
  9.      char output[100];
  10.  
  11.      cout << "Enter a file name and press ENTER: " << endl;
  12.      cin.getline(filename, 200);
  13.      ofstream file_out(filename);
  14.  
  15.      cout << filename << " was opened. Enter a line to enter and press ENTER(type @@@ to exit): " << endl;
  16.      cin.getline(output, 100);
  17.  
  18.      if(! file_out){
  19.           cout << filename << " could not be opened." << endl;
  20.           return -1;
  21.      }
  22.  
  23.      while(true){
  24.           if(strcmp(output, "@@@"))
  25.                break;
  26.  
  27.           file_out << output << endl;
  28.      }
  29.      file_out.close();
  30.      return 0;
  31. }
Advertisement
RAW Paste Data Copied
Advertisement