如何在这个C printf代码中创建一个新行?

时间:2014-09-22 05:38:22

标签: c

printf("%c Trying to forget someone you love is like trying to remember someone you never knew \n\n",3);

变得像在vb.net中一样:

printf("%c Trying to forget someone you love is like trying to" & 
"remember someone you never knew \n\n",3); 

我们在新行上添加下一个字符串....如何用C语言连接字符串。

3 个答案:

答案 0 :(得分:2)

两种方式:

printf("%c Trying to forget someone you love is like trying to "
       "remember someone you never knew \n\n",3);

字符串文字可以像多个引用部分一样编写。它仍然只是一个字符串。这种方式可以有缩进和评论。


printf("%c Trying to forget someone you love is like trying to \
remember someone you never knew \n\n",3);

您可以通过将反斜杠作为 last char排成一行来拆分字符串文字。如果您希望最后使用\n\,则结果字符串中不会有换行符。此外,如果你缩进第二行,该空格将进入字符串,通常不是你想要的。

答案 1 :(得分:0)

只需将琴弦放在彼此之后,两者之间没有任何操作员。

printf("%c Trying to forget someone you love is like trying to "
       "remember someone you never knew \n\n", 3);

它将被编译器视为一个长字符串。

答案 2 :(得分:0)

你只需要写

printf("%c Trying to forget someone you love is like trying " 
       "to remember someone you never knew \n\n",3);

两个并列的字符串文字将成为一个。