Type detection

hi everyone...
i´ve got a little problem here...

I have a Char* and it will have a number, that can be an int or a float...

but i need to know what is this type...

if its an int, i have to print "INT" or "FLOAT" otherwise

anyone knows how do i do that?
Was the pointer casted from the original type?
For example
1
2
float a=40;
char *p=(char *)&a;

If that's the case, then it's impossible because the cast destroyed all type information.

If the pointer points to a decimal representation of the number, such as "40.5", then you can find out the type by checking if it has decimals. If it doesn't then it's an int. Otherwise it's a float.
i´ve search for a " . " in the char...

it works =)

thx for the advice
^^
Topic archived. No new replies allowed.