C风格字符串与printf函数

 C风格字符串的妙用

1. 打印时最末次换行,其他空格。

for (size_t i = 0; i < len; ++i) {
    printf("%d%c", i, " \n"[i == len - 1]);
}

2. printf();函数还支持双引号连续,使得字符串可以拼接。但是中间不允许有逗号分隔。

printf("1" "2" "3");    //123

猜你喜欢

转载自blog.csdn.net/Hello_MyDream/article/details/86743686