std::endl in a string variable?

前端 未结 4 2006
青春惊慌失措
青春惊慌失措 2021-01-18 16:03

Hi i want to save multiply lines in a string. I got a string logstring and i want to save multiplay error logs which i later can print in a txt file or as a console output.

4条回答
  •  [愿得一人]
    2021-01-18 16:34

    std::endl isn't only a \n (newline) character, but it also flushes the stream.

    If you have a file open in 'text-mode', your operating system should replace \n with the correct platform specific end of line character(sequence). So simply appending a \n should be fine. Portable end of line (newline)

    Also note that by default, standard input and output are opened in textmode with msvc.

提交回复
热议问题