Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
char *values = " 3 1 4 15"; vector<int> array;
我想用值填充数组,
3,1,4,15
有没有一种巧妙的方法可以使用 stl 复制算法来做到这一点?
确实有:
std::istringstream iss(values); std::copy(std::istream_iterator<int>(iss), std::istream_iterator<int>(), std::back_inserter(array));