I need to write a program that reads values from an external file. I am creating the file using Notepad, but in putting in values do I need to separate the values by any symbol like a semicolon? Or is it sufficient to put the values on separate lines?
First you have to include the <fstream> library:
#include <fstream>
Then define it:
ofstream out_stream;
ifstream in_stream;
Then create your string that will be written to the file:
string name;
Finally, ask the user to input the name and open your out_stream:
cin>>name;
out_stream.open(name.c_str());
out_stream << name << "\n";
cout<<"\n";
out_stream.close();