我试图在使用" scanf"作为输入后使用数字。功能。例如,如果我输入2,我想知道如何在我的代码的后期使用它(可能用它调用另一个函数)。
#include<stdio.h>
int main(){
int Input;
scanf("%d",Input);
printf("%d", Input);
//here is the place where I want to use the Input
return 0;
}
在代码示例中,在命令printf之后我应该如何进一步开发代码。
答案 0 :(得分:0)
我不确定这是否能回答你的问题。您不必打印值来使用它。从scanf中取出它后,您可以随时随地使用它。
#include<stdio.h>
int inc(int input) {
int val = input + 1;
return val;
}
int main(){
int Input;
scanf("%d",&Input); //dont forget &
//now you have the input saved, do anything you want with Input
printf("%d",Input); // you can print the value you scanned
int out = inc(Input); //you can put it in a new function
printf("%d %d",Input,out); //you can output it again, "printf" is also another function
return 0;
}