fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. string stuff = "5x^9";
  9. istringstream sss(stuff);
  10. double coeff;
  11. char x, sym;
  12. int degree;
  13.  
  14. sss >> coeff >> x >> sym >> degree;
  15. cout << "the coeff " << coeff << endl;
  16. cout << "the x " << x << endl;
  17. cout << "the ^ thingy " << sym << endl;
  18. cout << "the exponent " << degree << endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 4248KB
stdin
Standard input is empty
stdout
the coeff 5
the x x
the ^ thingy ^
the exponent 9