fork(42) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. istringstream iss("2.832 1.3067 nana 1.678");
  9. double num = 0;
  10. while(iss >> num || !iss.eof()) {
  11. if(iss.fail()) {
  12. iss.clear();
  13. string dummy;
  14. iss >> dummy;
  15. continue;
  16. }
  17. cout << num << endl;
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
2.832
1.3067
1.678