diff options
author | Oskar <[email protected]> | 2024-10-06 21:28:38 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-10-06 21:28:38 +0200 |
commit | 0921163e1f88c8e80991f0c94e0fc70c6dcba72d (patch) | |
tree | 878b49f5971e6469b9bb65e5c69ce37644ad8730 /8p9.cpp | |
parent | 19419d86cb88981df7973b08a0da6373abfba566 (diff) |
more
Diffstat (limited to '8p9.cpp')
-rw-r--r-- | 8p9.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#include <iostream> +#include <sstream> + +/* + * + * 8.9 + * + * + */ + +std::istream &read_print_report(std::istringstream &rpr) { + + std::string a; + while(rpr >> a) { + std::cout << a; + } + + if(rpr.good()) { std::cout << "good" << std::endl; } + if(rpr.eof()) { std::cout << "eof" << std::endl; } + if(rpr.fail()) { std::cout << "fail" << std::endl; } + if(rpr.bad()) { std::cout << "bad" << std::endl; } + rpr.clear(); + std::cout << "--- cleared --- \n"; + if(rpr.good()) { std::cout << "good" << std::endl; } + if(rpr.eof()) { std::cout << "eof" << std::endl; } + if(rpr.fail()) { std::cout << "fail" << std::endl; } + if(rpr.bad()) { std::cout << "bad" << std::endl; } + return rpr; +} + + +int main () { + + std::string s = "wow i love c++!! This is so cool! I am loving these features, it really feels like C but without having to reimplement everything!"; + std::istringstream a(s); + read_print_report(a); + return 0; +} |