romke@targon.UUCP (Romke Teerenstra) (10/22/87)
This afternoon I had this weird idea to print void values, and to
cast values to void, just to see what would come out.
My thoughts were : since void is a type, I can declare such a variable.
So I can assign a value of that type to it.
So I can cast something, say an integer, to it.
So I should be ble to write a program what does just that.
To my suprise
however, this didn't even compile on the two types of machines
we have here. One compiler complained about a void type being declared
of which he didn't know the size, and the other just stopped, because
he couldn't cast a value to void.
After talking it over with two of my collegues,
We think this program is legal, but don't know for sure.
So I ask you:
1 Is this program legal?
2 If not, what is wrong with it?
3 If it is, what should be printed?
#include <sys/types.h>
main()
{
void v;
v =
(void)345;
printf("%d %c %X\n",(int)v,(char)v,(int)v);
}
As this is cross-posted, please send Follow-ups to comp.lang.c
Romke