#include <iostream.h>
int x; //global variable
void main()
{
int x; //local variable
for(int x=0; x<10; x++)
{
cout<<"x in for="<<x;
//how to access global x ?
//how to access local x ?
}
}
I know i can access to the global x with :: , but how should i access to the local x variable in the for?
Also I noticed you are using void main() and <iostream.h> and I am guessing your compiler is quite old.
Consider getting a newer one (there are a lot of them free of charge).