hi guys,
i wonder how you can can take a string from a particular file and assign that to a variable.
for example here is the file named 'isbn.txt'
123-456-789-0
87-345-21-347
09-876-543-21
and my code, as far is i can write it:
int fromfile()
{
string filename;
ifstream fin;
string isbn;
cout << "enter the filename: ";
cin >> filename;
fin.open(filename.c_str());
if (fin.fail())
{
cerr << "error. file not found" << endl;
return 0;
}
//isbn = ?????
// i dunno how to assign isbn in the file to my isbn variable
}
I want to assign the isbn from my file (eg. 123-456-789-0)
to the isbn variable in the code.
so if anyone know how to do that, please help.
thank you