Parse string containing numbers into integer array

前端 未结 3 1986
终归单人心
终归单人心 2020-12-09 04:06

A String is given as an input which consists of numbers and I want to convert it into integer arrays in C++.

#include 
#include 

        
3条回答
  •  囚心锁ツ
    2020-12-09 04:41

    i don't know if you find the answer for your updated question or not. if you don't you can easily do it by the code

    for (string::iterator it = num.begin(); it != num.end(); ++it) {
        if (*it == ',') {
            *it = ' ';
        }
        else continue;
    }
    

    this code removes all your colons and replaces them by space. then you can do just normally

提交回复
热议问题