
Untitled
By: a guest on
Aug 20th, 2012 | syntax:
None | size: 0.70 KB | hits: 7 | expires: Never
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
cout << "What would you like the filename to be: ";
string FileName;
getline(cin, FileName);
ofstream Pile;
Pile.open(FileName);
string line;
string Read;
do{
cout << "Type into the text file: ";
getline(cin,line);
if(line != "y" && line != "n")
{
Pile << line << endl;
}
}
while(line != "y" && line != "n");
Pile.close();
system("CLS");
cout << "This is what you typed: \n\n";
ifstream File;
File.open(FileName);
if(File.is_open())
{
while(!File.eof())
{
getline(File, Read);
cout << Read << endl;
}
File.close();
}
else
{
cout << "Could not open File!\n";
}
cin.get();
return 0;
}