我认为 C 字符串可以用一个且只有一个带引号的字符串来初始化。我只是想知道这是怎么正确的?
char const help_message [] =
"Usage: %s [options] files ...\n"
"\n"
"Options include:\n"
" --verbose -v Be verbose\n"
" --help -h Print this help message\n"
" --output -o Specify output file\n"
"\n" ;
printf (help_message, argv [0]) ;
最佳答案
compiler将自动连接相邻的字符串。
这对于提高可读性非常有用,如您的示例或某些预处理器函数:
#define LOG(x) printf("%s", "Logging: " x)
LOG("HeyHey");
非常人为的例子,但明白了要点。
关于c - 用多个引号引起来的字符串初始化 C 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1823474/