I'm trying to turn a txt file into a string
so far I have got the program to write words into a txt (one per line) and am trying to get it to bring them back in as one string but am unsure of how to do this
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
int x;
int y = 0;
ofstream outputFile;
outputFile.open ("names.txt", std::ios_base::app);
cout << "How many names would you like to enter?\n";
cin >> x;
cout << "Please enter your " << x << " names\n";
string name;
while (y<x)
{
cout << y << " ";
cin >> name;
outputFile << name << endl;
y=y+1;
}
outputFile.close();
}