[ create a new paste ] login | about

Link: http://codepad.org/zi9WGqG2    [ raw code | output | fork ]

slevy1ster - C++, pasted on Nov 9:
#include <iostream>
#include <string>
#include <boost/algorithm/string.hpp>
#include <sstream>

using namespace std;

int main(){
    string line = "1,2,3\n4,5,6\n7,8,9";
    string arr[3];
    int i = 0;

    boost::erase_all(line, ",");
    boost::erase_all(line, "\\n");
    stringstream ss(line);

    while (ss.good() && i < 3){
        ss >> arr[i];
        ++i;
    }
    for(i = 0; i < 3; i++){
        cout << arr[i] << endl;
    }

    return 0;
}


Output:
1
2
3
123
456
789


Create a new paste based on this one


Comments: