it's my frist publication and i have a question- I have a .txt file that I want to separate by the ",". Example: example1,example2,example3,example4 I want to get example1 and store in an array and so on for example2 , example3, example4. string[0] = example1 string[1] = example2 etc....
Asked
Active
Viewed 87 times
1 Answers
0
getline by default will split input by end-line chatracter, but can do for any character, including ',' - see example (using a stringstream):
std::string input = "word1,word2,word3";
std::stringstream sstream(input);
std::string word;
while(std::getline(sstream, word, ',')) {
std::cout << word << '\n';
}

benroberts999
- 393
- 1
- 10