如何使用printf在字符串中打印多个变量?

agh*_*ghd 6 c printf syntax-error

我想找到两个数字的最大值,然后打印出来.我想要打印所有三个数字.我使用以下代码.

#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();

}
Run Code Online (Sandbox Code Playgroud)

但是,我收到两个语法错误(请参见附图).有人可以帮帮我吗?

Aad*_*kar 17

将输出打印的行更改为:

printf("\nmaximum of %d and %d is = %d",a,b,c);
Run Code Online (Sandbox Code Playgroud)

请参阅此处的文档


LCO*_*AJA 5

printf("\nmaximum of %d and %d is = %d",a,b,c);
Run Code Online (Sandbox Code Playgroud)