[Courses] [C] Beginner's Lesson 4A: Quibbles...
Daniel.
cristofd at hevanet.com
Fri Oct 11 11:01:28 EST 2002
> > > > Strings are arrays of characters. The special character `\0' (NUL)
>> > > indicates the end of a string.
>> >
>> > And is just a zero, by the way. Saying '\0' instead of 0 emphasizes
>> > its function as a string-terminator to the human reader, but makes no
>> > difference to the compiler.
>
>You are absolutely correct! A zero is a zero is a zero and will always
>be a zero. The NUL is zero. I was thinking of the character "0" and
>got confused. I'm sorry.
No problem at all. I could have been clearer.
The ASCII character NUL (used as a string terminator) has the value 0;
in C it can also be written as '\0' or 0x00.
The ASCII character 0 (used in outputting numbers) has the value 48;
in C it can also be written as '0' or '\x30' or 0x30 or '\60' or 060.
(30 is hexadecimal, 60 is octal.)
So since this email is ASCII text, wherever "0" appears in it, it's
really stored in memory as 48, just as the lowercase "a" is stored as
a 97 and the semicolon ";" is stored as a 59.
However, I think the string-terminator NUL ('\0') has the value 0
even in non-ASCII systems like the benighted EBCDIC. But '0' and 'a'
and so on might have totally different values. One purpose behind
saying 'a' in single quotes instead of 97 in the first place was to
make C programs portable in spite of that fact.
>Thank you very much for your help!
Very welcome.
-Daniel.
--
() ASCII ribbon campaign
/\ against HTML mail
More information about the Courses
mailing list