Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.     string line = "1,2,3,4,5";
  8.  
  9.     while (line.find(",", 0) != string::npos){
  10.         int comma_pos = line.find(",", 0);
  11.         double value = atof(line.substr(0, comma_pos).c_str());
  12.  
  13.         cout << value << endl;
  14.  
  15.         line = line.substr(comma_pos + 1, line.size() - comma_pos - 1);
  16.     }
  17.     cout << atof(line.c_str()) << endl;
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement