fajar sss wrote:
I define the constant string. Then i want to compare
string from file with this constant string.
What must i do? thanks before.
Include file stream support with:
To open a file "fred" for reading:
std::ofstream file( "fred" );
This returns 0 if the file couldn't be opened.
To close a file:
To check if you've reached the end of the file:
if( file.eof() )
/* end of file */;
To handle strings, use the string class because it allows you to easily
std::string name = "Tom";
if( name == "Fred" )
To read from the file:
file >> name;
file >> number;
file >> name >> number;