0
foo not called in main Why it needs input ?
#include <iostream> using namespace std; int foo(int bar){ cin>>bar; cout<<bar; } int main() { // foo(0); return 0; }
3 Réponses
+ 2
When we use "int foo(int bar){return 0;}" , it means whenever we have to call "foo()" it needs to be passed with a integer value in it , like "foo(54)".
If you want to insert value of "bar" from user(at runtime" you can use this one.
#include <iostream>
using namespace std;
int foo(){
int bar;
cin>>bar;
cout<<bar;
return 0;
}
int main() {
foo();
return 0;
}
+ 6
Just Curious to know.. what is foo?
+ 1
it's weird that it's commented out... but the input would allow you to set a different default value before user input every time you call the function but it does seam useless here. I might be missing something.