Answer the question
In order to leave comments, you need to log in
How to split a file by hyphenation?
This code should split on \n
//Скажем s равен файлу test.txt:
/*
1
12
123
*/
std::string separator = "\n";
auto start = 0U;
auto end = s.find(separator);
while (end != std::string::npos)
{
std::cout << s.substr(start, end - start) << std::endl;
start = end + separator.length();
end = s.find(separator start);
}
Answer the question
In order to leave comments, you need to log in
Is it okay that you have separator on top, and delim in the loop?
If you ask a question about the code, it makes sense to attach the entire code, in the form in which it raises the question.
But it just outputs the entire file.
std::cout << s.substr(start, end - start) << std::endl;
std::cout << s.substr(start, end - start) << ", " << std::endl;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question