+ 1
Why does an int pass a value when defined outside the main() function, but not inside for a for loop?
this works #include <iostream> using namespace std; int a; int main() { for (a; a < 10; a++) { cout << a << endl; } return 0; } but this doesnt #include <iostream> using namespace std; int main() { int a; for (a; a < 10; a++) { cout << a << endl; } return 0; }
3 Respuestas
+ 6
The loop condition should be writen: (; a < 10; a++) (try removing the initial "a")
+ 5
When inside it's "local" and only the parent can access it.
+ 1
yes but shouldn't all of the data that is local to the same function be able to be accessed in side that function?