Mega Code Archive

 
Categories / C++ Tutorial / File Stream
 

Attempt to read from empty stream

#include <iostream> using std::cout; using std::endl; #include <string> using std::string; #include <sstream> using std::istringstream; int main() {    string input( "" );    istringstream inputString( input );    // attempt to read from empty stream    long value;    inputString >> value;    if ( inputString.good() )       cout << "\n\nlong value is: " << value << endl;    else       cout << "\n\ninputString is empty" << endl;    return 0; } inputString is empty