Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 7  |  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<fstream>
  3. #include<string>
  4. #include<sstream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. cout << "What would you like the filename to be: ";
  11. string FileName;
  12. getline(cin, FileName);
  13.  
  14. ofstream Pile;
  15. Pile.open(FileName);
  16. string line;
  17. string Read;
  18.  
  19.  
  20. do{
  21. cout << "Type into the text file: ";
  22. getline(cin,line);
  23. if(line != "y" && line != "n")
  24. {
  25. Pile << line << endl;
  26. }
  27.  
  28. }
  29. while(line != "y" && line != "n");
  30.  
  31. Pile.close();
  32. system("CLS");
  33. cout << "This is what you typed: \n\n";
  34. ifstream File;
  35. File.open(FileName);
  36.         if(File.is_open())
  37. {
  38.         while(!File.eof())
  39.         {
  40.       getline(File, Read);
  41.           cout << Read << endl;
  42.         }
  43.         File.close();
  44.        
  45.        
  46. }
  47. else
  48. {
  49. cout << "Could not open File!\n";
  50. }
  51. cin.get();
  52.  
  53. return 0;
  54.  
  55.  
  56.  
  57. }