I have a global variable and a local variable with the same names. Can I copy the local variable to the global variable (assign) without first assigning the value of the global variable to some temporary variable (using extern) and then assigning the temporary variable to the global variable? I need to do something like this:
#include<stdio.h>
int myVariable = 50;
void myFunction()
{
int myVariable;
myVariable /*global*/ = myVariable /*local*/;
}
Is there some way in C to do it (without using temporary variables (or pointers in case of arrays))? I found it's possible in C++, Java or C# using keywords like this, super, base, etc. but couldn't find a solution in C.
I have already referred to How can I access a shadowed global variable in C?