Array elements

K

Kumar

How should I declare the array elements being half word?
and the array elements of the type byte in C??

Please help


Kumar
 
C

Chris Dollin

Kumar said:
How should I declare the array elements being half word?

There's no such C type: you can't portably do it.

If by "half word" you mean some implementation-specific notion,
you'll have to see what your implementation says. It may be,
for example, that your implementation maps C shorts to what
you're calling a "half word" (but another one does not).

If you can use the C99 specified-int types you might be able
to pick one of those that corresponds to your "half word".

Or ... it may be that you don't need to worry about any of
this nonsense. /Why/ do you want to use "half words"?
and the array elements of the type byte in C??

In C, the nearest you'll get is a (n unsigned) char. This
may or may not correspond to what you want. Why do you want
to use "type byte"?
 
F

Frederick Gotham

Chris Dollin posted:

In C, the nearest you'll get is a (n unsigned) char. This
may or may not correspond to what you want. Why do you want
to use "type byte"?


I think it's *exactly* what he wants. I consider "char" to be synomonous
with "byte".

(But I don't consider a byte to always be 8 bits.)
 
C

Chris Dollin

Frederick said:
Chris Dollin posted:


I think it's *exactly* what he wants. I consider "char" to be synomonous
with "byte".

(But I don't consider a byte to always be 8 bits.)

Until I know what the OP wants "arrays of byte" for, I can't tell if
it's "exactly" what they want.

They might want them for Cunning Type Overlays.
 
P

pete

Frederick said:
I consider "char" to be synomonous with "byte".

I consider those two as synonomous in a string context,
but in a raw memory context,
unsigned char is what to use to manipulate bytes.
 
S

santosh

Kumar said:
How should I declare the array elements being half word?

Define what "half word" is.
and the array elements of the type byte in C??

unsigned char array[N] declares an array of N elements of type unsigned
char, which is the unsigned form of byte, as defined by the C standard.

Maybe your definition of byte is different. If so, provide more
specifics.
 
K

Keith Thompson

Frederick Gotham said:
Chris Dollin posted:

I think it's *exactly* what he wants. I consider "char" to be synomonous
with "byte".

(But I don't consider a byte to always be 8 bits.)

Maybe. It's certainly true that a char occupies exactly one "byte" by
definition in C, but that's a C-specific definition of the term
"byte". Given that the OP is asking about this in the first place, I
doubt that he's familiar with the C definition.

I don't think there's any further point in speculating about what the
OP really wants. He can come back and clarify what he means.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,976
Members
47,536
Latest member
MistyLough

Latest Threads

Top