🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4202

Re: Is this a good Idea??

#4202
From: Paul Long
Date: Sun, 08 Oct 1995 21:12
35 lines
1727 bytes
In article 458816$ki0@zonker.cs.ucsb.edu, schapel@cs.ucsb.edu (Steve E.
Chapel)
writes:
>ua302aa@sun2.lrz-muenchen.de (Kurt Watzka) writes:
>>aprc@pcmail.nerc-bas.ac.uk (A P R Cooper) writes:
>>As would fputc/fgetc. BTW what is the difference between a byte and 
>>a char, as far as C is concerned? (Hint: Both words denote the same
>>as long as you are talking about C).
>I don't think that's true. Isn't a char definde to be *at least* 8 bits
>(in other words a byte) in the ANSI C standard? A char could be 2 bytes,
>or 4 bytes, or 256 bytes, for that matter.

This is a common misunderstanding. A byte, in Standard C, is not an 8-bit
unit of
storage: "A byte is composed of a contiguous sequence of bits, the number of
which is implementation-defined." And that number is defined by the value of
CHAR_BIT in limits.h, which must be at least 8. So, for example, you could
have
8-bit bytes, 9-bit bytes, or 16-bit bytes.

Because "the sizeof operator yields the size (in bytes) of its operand" and
the result
is1 for the char types, a char object always occupies exactly one byte of
storage,
not "2 bytes, or 4 bytes, or 256 bytes," at least using Standard C's
definition of a
"byte."

When talking about bytes in the context of C, you have to be very careful. Do
you
mean simply 8-bits or the formal, more elusive definition provided in the
Standard?

Paul_Long@ortel.org
plong@perf.com
Technical Details
Message-ID: <1139933150.15676234@ortel.org>
Path: arc1-ca.pugleaf.net!uu4news.netcom.com!otsrvr!Paul_Long

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!uu4news.netcom.com!otsrvr!Paul_Long
From: Paul_Long@ortel.org (Paul Long)
Reply-To: Paul_Long@ortel.org
Newsgroups: comp.std.c
Distribution: world
Subject: Re: Is this a good Idea??
Date: 08 Oct 1995 21:12:58 GMT
Message-ID: <1139933150.15676234@ortel.org>
Organization: Oregon Telcom