"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
rahul wrote:
[...]
How can I accomplish this in C?
I am using [GNU C].
Is there a way to have a byte datatype in C?
No.
Not in C or any other computer programming language.
ERT is posting nonsense again.
C does not have a built-in type called "byte", but it's perfectly
reasonable to declare one of your own:
typedef unsigned char byte;
C overloads the char types (char, unsigned char, signed char) as both
character types, representing text and control characters used for
input/output, and as the fundamental unit of storage. This is, in my
opinion, a design flaw in the language, but we're stuck with it. A
typedef like the above can be a useful way to avoid the ambiguity.
Or you can just use "unsigned char" directly, without the typedef, and
keep in mind that the name "char" doesn't necessarily imply textual
data.
The C99 standard defines a "byte" as an "addressable unit of data
storage large enough to hold any member of the basic character set of
the execution environment". Whether an "addressable unit of data
storage" is better referred to as a type or as a size is another
question, but not a particularly interesting one IMHO.
Other languages are off-topic here, but at least one language (Java)
does define an intrinsic type called "byte".
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.