gpt4 book ai didi

c - C如何在printf语句中编译 "senthil"“kumar”?

转载 作者:行者123 更新时间:2023-11-30 21:18:12 25 4
gpt4 key购买 nike

在使用 printf 语句时,我对 C 语言的基础知识有疑问。这就是我的代码的样子。

#include<stdio.h>
int main(){
printf("%s %s",("senthil""kumar"),("hello""world"),("stack""overflow");
return 0;}

我有一个类似的输出,Senthilkumar Hello World

但我不知道这段代码是如何工作的。你能帮我弄清楚它是如何工作的吗...提前致谢。

最佳答案

两个连续的字符串文字由编译器合并。

即以下示例是等效的:

// 1:
"foo" "bar"
// 2:
"foobar"
// 3:
#define FOO "foo"
FOO "bar"

您不需要所有这些内括号(而且末尾缺少 ))。

关于c - C如何在printf语句中编译 "senthil"“kumar”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27730959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com