From 0921163e1f88c8e80991f0c94e0fc70c6dcba72d Mon Sep 17 00:00:00 2001 From: Oskar Date: Sun, 6 Oct 2024 21:28:38 +0200 Subject: more --- 8p9.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 8p9.cpp (limited to '8p9.cpp') diff --git a/8p9.cpp b/8p9.cpp new file mode 100644 index 0000000..5889ca2 --- /dev/null +++ b/8p9.cpp @@ -0,0 +1,38 @@ +#include +#include + +/* + * + * 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; +} -- cgit v1.2.3