Has a way to get the datatype in C?

For example:

```

int foo;

if (foo is int)
{
    // do something
}

```

or something like:

```

if (typeof(foo) == typeof(int))
{
    // do something
}

```

Thanks in advance.
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
Since C11, you can do that with `_Generic`:

```
if (_Generic(foo, int: 1, default: 0)) // if(typeof(foo)==int)
{
    // do something
}

```
The only time you wouldn't know the type is if the type of foo is defined by a typedef -- if that's the case, your example should reflect it. And why do you need to something dependent on the type? There may well be a way to solve your actual problem, but you haven't presented your actual problem.