C++中几行的相同命令

use*_*841 0 c c++ windows winapi

我想在C++中用几行代写一个变量.更准确地说是在WINAPI中.

类似的东西:(如果\是执行它的命令,)

str=" This is a sample file trying to write multiple lines. \n but it is not same as line break. \
I am defining the same string over several lines. This is different from using backslash n. \
This is not supposed to print multipline in screen or in write file or on windows display. This\
is for ease of programming.";
Run Code Online (Sandbox Code Playgroud)

这个问题是我得到了"|||" 无论我在我的代码中使用过\.我不希望它出现.我该怎么办?

Kon*_*lph 6

有几种选择.这是两个:

  1. 将字符串的内容放入文件中,并将文件内容读入字符串.当你发现自己使用了很多长串时,这可能是"正确的"方式.

  2. 使用以下语法:

    str = "This is a string that is going over several lines "
          "but it does not include line breaks and if you print "
          "the string you will see that it looks like it was "
          "written normally.";
    
    Run Code Online (Sandbox Code Playgroud)

    - C++允许您一个接一个地编写几个字符串文字,并在编译时自动连接它们.也就是说,"a" "b"就"ab"C++而言,是一样的.