I can extract the data and print it out but i want to get a copy of the data and run the Replace Algorithm I have on the bottom of my code. Is there a way to get the data that is being extracted from myfile >> n to a string so I can run the algorithm ?
Numbers.txt contains the following :
32
15
27 86 95
738 2
13
7
8
ifstream myfile;
myfile.open("numbers.txt");
if(!myfile)
{
cout << "Error! Could not be opened!" << endl;
return 0;
}
char n[256];
while(!myfile.eof())
{
myfile >> n;
cout << n << endl;
}
myfile.close();
// Replace algorithm
string a; // Would be the data that myfile >> n; is getting from numbers.txt
string b("LSU");
copy(b.begin(), b.end(), a.begin() + a.find('7'));
cout << a << std::endl;