如何在多行C / C ++中编写长字符串?
长字符串可以通过使用两个双引号(“”)来在中间的任意点处断开字符串来多行编写。
给出了一个用C语言演示此程序的程序,如下所示。
示例
#include <stdio.h>
int main() {
char *str = "This is the method "
"to write long strings "
"in multiple lines in C";
puts(str);
return 0;
}输出结果
上面程序的输出如下。
This is the method to write long strings in multiple lines in C
现在让我们了解上面的程序。
可以使用两个双引号(“”)将字符串str多行写入,以在中间的任意点将字符串断开。然后使用puts显示字符串。显示此代码段如下。
char *str = "This is the method " "to write long strings " "in multiple lines in C"; puts(str);
热门推荐
10 小红书生日祝福语简短
11 祝福语简短唯美10字
12 恭喜新郎父母简短祝福语
13 入学校简短祝福语
14 鼓励孩子小考祝福语简短
15 表妹结婚祝福语简短藏语
16 薛之谦祝福语简短
17 老公生日祝福语简短好看
18 双十一祝福语大全简短