Character constants

Rob Carriere rob at sleepy.eng.ohio-state.edu
Fri Mar 3 11:40:45 AEST 1989


In article <7447 at pyr.gatech.EDU> curci at stat.fsu.edu (Ray Curci (scri)) writes:
>Why is therer so much discussion about  character discussions?
>
>A simple printf("%d", sizeof('x') ); reveals that a character constant
>(at least both on sun3 and ultrix 11/780) are the same as an int (4 chars).
>Isn't it a lot easier to execute a simple test program than to try to
>look up this type of information?

Yes, it is (usually) much easier.  Yes, you should do it, *to test
your compiler*.  No, it does not answer the question.  A compiler does
not a language definition make.

Secondly, your test here is insufficient.  For example, the computer
that is currently bearing with me chattering all over the place will,
on request, also happily provide the information that

sizeof(long) == sizeof(float) 

The assumption that this would mean that the types long and float are
the same seems rather unsafe.

SR



More information about the Comp.lang.c mailing list