Chad said:
I was wondering if it is possible to pass type int (as opposed to its
value) when I call foo(). Could I do this using pointers in C?
I'm fairly sure the answer is no, but it's not at all clear what you
mean.
The type int doesn't have a value. A type can be thought of as, among
other things, a set of values. 5 is one of the values of type int,
and that's the value you're passing to foo; it's still a value of type
int when foo gets it, and it's stored in an object of type int (the
parameter object y).
Some languages support something called "templates" (as in C++) or
"generics" (as in Ada), and let you create an instance using a
particular type as an argument. C doesn't, but you can do something
similar with macros:
#define FOO(type) ...
...
FOO(int)
but that's just textual substitution. Even C++ templates and Ada
generics do the substitution at compile time.
Of course you can pass a pointer to an int rather than an int.
Some more exotic langauges might support someting like types as
values, but that's well beyond what can be done in C (at least
directly).