std :: cout을 stringstreams로 리디렉션하는 것과 관련하여 많은 게시물을 읽었지만 리디렉션 된 문자열을 읽는 데 문제가 있습니다.리디렉션 된 cout -> std :: stringstream, EOL을 보지 않았습니다.
std::stringstream redirectStream;
std::cout.rdbuf(redirectStream.rdbuf());
std::cout << "Hello1\n";
std::cout << "Hello2\n";
while(std::getline(redirectStream, str))
{
// This does not work - as the contents of redirectStream
// do not include the '\n' - I only see "Hello1Hello2"
}
초기 출력 내에서 새로운 줄을 고를 필요가 있습니다. 어떻게 할 수 있습니까?
감사합니다.
귀하의 정보는 내 컴퓨터에서 작동합니다. (Visual C++ 2008) – KeatsPeeks