Really EASY problem to solve.....

How do I declare a variable that CAN be changed but can be used in all functions of a program?

Like if I declare a variable in main, I can't use it in main2, get it?

I need a way to refer to and access a variable from all points of a program and change its value.

I'm not kidding, I really don't know how to do this and it's probably so simple....So please, some help. I need to know this for this program I'm almost finished with(the program moves from function to function and I need to be able to grab the contents and access/view them from all functions, but a constant variable used with #define is constant; won't change. I need a way to do this with a changeable variable)!
Last edited on
1
2
3
4
5
int thisVariableCanBeAccessedGlobally = 0;
int main()
{
     cout << thisVariableCanBeAccessedGlobally;
}
Last edited on
Huh?

I don't get it....Explain a bit of it, please?
Last edited on
If you declare the variable outside of any function, and above any functions that use it, you can access it from all of those functions.

Then what are static variables good for?

Also, why did you take so long to answer?
Last edited on
No one is going to kick him? He has threads all around this site just completely trolling.
Somehow, I think the fact that for newer users the "Report" feature has been changed to a "Report+Delete" feature has made some of us a bit more hesitant to use it...

-Albatross
Yes, but the thing is while he obviously acts stupid, he does technically not violate any rules right now (that I am aware of). A bit annoying, yes, but better than his previous misdeeds.
Well... there was one thread with an inappropriate title.

-Albatross
closed account (z05DSL3A)
Yes, but the thing is while he obviously acts stupid, he does technically not violate any rules right now (that I am aware of). A bit annoying, yes, but better than his previous misdeeds.

I was trying to work out if he was a complete fool, trying not to get banned (the account has been suspended), or a Wind-up merchant that was trying to get passed the instant delete milestone. I was just waiting for the abusive rant.
I was going to give helpful input but when people on forums complain about how long it took for others to give an answer it bothers me. just sayin...
Topic archived. No new replies allowed.