fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <sstream>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. float v2;
  10. string m2 = "1 23 45 6";
  11. for (int i = 0; i < m2.length(); i=m2.find_first_of(' ', i+1)) //to convert every element in m2 into float
  12. {
  13. v2 = atof(&m2[i]);
  14. printf("%.2f\n", v2);
  15. }
  16.  
  17. system("pause");
  18. return 0;
  19. }
Success #stdin #stdout #stderr 0s 3228KB
stdin
Standard input is empty
stdout
1.00
23.00
45.00
6.00
stderr
sh: 1: pause: not found