How can I unset a variable in C to allow usage of the same name with different datatype later on?

c, unset, variables

Solution

You can't. The closest you can get is creating separate scopes and using the same variable name in them:

 {
     int val;

     // do something with 'val'
 }

 {
     double val;

     // do something with 'val'
 }

Problem

I want to use the same variable name with a different datatype in C program without casting. I really wanna do that don't ask why. So how can I do that ? And how can I handle the error if this variable doesn't exist while doing prophylactic unsetting ?

Original source