How do you break the char mass by number through the separator?
-
Hi, I have a question: from the text file, I'm pulling a line into a char mass, which looks like {5_12_-3_89_1_-1#}, can we split it into separate numbers separated by the "_"? That the first element of the mass is 5, 2-12, 3-3, etc.?
-
The most correct (C++) execution option through
std::getline()
:const char* line = "5_12_-3_89_1_-1#"; std::string num; std::stringstream nums(line); while (std::getline(nums, num, '_')) { //work with num }