fork download
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. std::stringstream stream;
  8.  
  9. int source = 5;
  10. stream << source;
  11.  
  12. std::cout << "is eof before load ? " << std::boolalpha << stream.eof()
  13. << std::endl;
  14.  
  15. int loaded = 0;
  16. stream >> loaded;
  17.  
  18. std::cout << "The loaded value is " << loaded
  19. << std::endl;
  20.  
  21. std::cout << "is eof after load ? " << stream.eof()
  22. << std::endl;
  23. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
is eof before load ? false
The loaded value is 5
is eof after load ? true