如何调用一个包含 printf 的函数 - 在 printf 中但不打印输入两次的值? 下面编写的代码就是现在的样子,它打印插入的值。 我可以只使用该函数而不再次打印该值吗?
我可以使用 printf(roll(num))
#include<stdio.h>
int roll(int);
int main()
{
int num;
printf("%d",roll(num));
return 0;
}
int roll(int a)
{
printf("Enter a number between 1-6:\n");
scanf("%d",&a);
while(a<1 || a>6)
{
printf("Wrong input! please enter a number between 1-6:\n");
scanf("%d",&a);
}
return a;
}
最佳答案
只需调用该函数,无需 printf。
roll(num);
关于c - C 中 printf 的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53565122/