如何在多行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 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短