As you said, theVariable is "local" to main() function and the setValue() does not recognize/reset the value.
You either change the scope of the variable to global as suggested above,
or change the value by reference, meaning, either a pointer or reference type.
Pass the value by reference to function and let it change the passed-in value, then the main() would see the changed value.