Is it possible to make a variable (example: int a = 9) global while it is inside of a function?
Is it possible to make a variable (example: int a = 9) global while it is inside of a function?
Not quite. When a variable is within a function, it only has function scope and is not defined outside of that function. Therefore, when program execution leaves that function, the value stored in the variable is lost.
If you're just looking to keep the value of the variable intact when you leave the function (so you can come back to it later), look up the "static" keyword.
Additionally, you should try to write your code so you do not require the use of global variables. You can read here why global variables are bad.
Thank you for your responses