Re: Find the Data Type of Variable
- From: "Mike Wahler" <mkwahler@xxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 16:04:53 GMT
"chellappa" <N.Chellappa@xxxxxxxxx> wrote in message
news:1138722161.310948.281130@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi All,
> How to find the data type of the variable ?
The C language does not have a facility for doing this.
> is there any libaray
> function avaiable? Because i want create generic data type of some
> operation .
When you create an object, you know its type. E.g.:
int i;
double d;
If you keep track of this information yourself (e.g. with
a 'type flag' or such), you can implement 'generic' types
using a pointer to void (type 'void *'). Use a 'type
flag' to convey type information to a function. This is
how 'printf()' does it (e.g. "%d" in the first argument
tells it that the associated argument is type' int). Of
course things won't work if you don't actually pass the
proper type. IOW, 'void*' is quite useful, but needs
to be used with great care. A sharp, two-edged knife.
-Mike
.
- References:
- Find the Data Type of Variable
- From: chellappa
- Find the Data Type of Variable
- Prev by Date: Re: Find the Data Type of Variable
- Next by Date: Re: Trap representation
- Previous by thread: Re: Find the Data Type of Variable
- Index(es):
Relevant Pages
|