C语言 如何使用 printf 在字符串中打印多个变量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34598089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 12:17:18 来源:igfitidea点击:
How can you print multiple variables inside a string using printf?
提问by aghd
I want to find the maximum value of two numbers, and print it. I want to print all three numbers. I am using the following code.
我想找到两个数字的最大值,并打印出来。我想打印所有三个数字。我正在使用以下代码。
#include<stdio.h>
#include<conio.h>
main()
{
//clrscr();
int a,b,c;
printf("insert two numbers:");
scanf("%d%d", &a, &b);
c = (a>b) ? a : b;
printf("\nmaximum of %d",a," and %d",b," is = %d" c);
getch();
}
However, I receive two syntax errors (Please find the attached figure). Could anybody help me out with it?
但是,我收到两个语法错误(请找到附图)。有人可以帮我解决吗?


回答by Aaditya Gavandalkar
回答by LCO TEC BAJA
printf("\nmaximum of %d and %d is = %d",a,b,c);

