Null revisited (briefly)
Guy Harris
guy at auspex.UUCP
Thu Mar 2 04:48:49 AEST 1989
>>When you assign 'x' to a character, you are assigning an int to a
>>character. The reader knows that the type mismatch was intentional.
>
>Not if he knows the C language. A single character written within
>single quotes is a *character constant*. This isn't an int.
Wanna bet? The May 13, 1988 dpANS says:
3.1.3.4 Character constants
...
Description
An integer character constant is a sequence of one or more
multibyte characters enclosed in single quotes, as in 'x' or
'ab'. A wide character constant is the same except prefixed by
the letter L. ...
Semantics
An integer character constant has type "int". ...
>'\0' is a special case to permit the representation of non-graphical
>characters (also newline, tab, backslash, return, etc.) and is not
>the same as 0, which is an integer constant.
Wrong. '\0' *is* the same as 0.
More information about the Comp.lang.c
mailing list