在单个printf()语句中打印多个变量

时间:2018-10-27 04:44:23

标签: c printf

到目前为止我所拥有的:

printf("Entered string is %c", string, "with length %d", i,
"and ID number is %s", number, "with length %d", j);

我得到的结果是:

Entered string is 4

1 个答案:

答案 0 :(得分:0)

对于字符串,请使用%s而不是%c;如果您的ID是整数,请使用%d   而不是%s

 printf("Entered string is %s with length %d and
     ID number is %s with length %d",string,i, number, j);