hardcoded constants

Chris Torek chris at mimsy.UUCP
Fri Dec 23 07:42:50 AEST 1988


>>sizeof('\0') is equal to the size of an integer ....
>>Remember, in C, character constants are integer constants.

In article <410 at aplcen.apl.jhu.edu> arrom at aplcen.apl.jhu.edu
(Ken Arromdee) writes:
>I was under the impression that "sizeof" is done at compile time and isn't
>really a function, so this would correctly return 1.

sizeof is indeed not a function, yet sizeof('\0') is the same as
sizeof(0) and sizeof(int), which are usually not the same as sizeof(char).
The second `>>' line above is the key: the type of '\0' is int, not char.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list