Since your question is tagged "C", I'll answer about that language. Other languages may provide syntactic sugar or mechanisms to do what you want.
Defining a variable using the name of a variable existing in a greater scope is called shadowing: the inner definition shadows the outer one.
Below is an example:
int x = 42;
int main() {
int x = 0; // Here, `x` shadows the global `x`.
printf("%d\n", x); // Prints '0'
}
In C, there is no way to get the value of the shadowed variable.
On the style plan, shadowing is often considered a bad practice since it makes your code less legible and harder to refactor.