470,821 Members | 2,041 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,821 developers. It's quick & easy.

Array elements

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

Please help
Kumar

Jun 29 '06 #1
6 1416
Kumar wrote:
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"?

--
Chris "th i a signa elem (roun u)" Dollin
"Who do you serve, and who do you trust?" /Crusade/

Jun 29 '06 #2
Chris Dollin posted:

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"?

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.)
--

Frederick Gotham
Jun 29 '06 #3
Frederick Gotham wrote:
Chris Dollin posted:
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"?


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.

--
Chris "run away! run away!" Dollin
"Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/

Jun 29 '06 #4
Frederick Gotham wrote:
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.

--
pete
Jun 29 '06 #5
Kumar wrote:
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.

Jun 29 '06 #6
Frederick Gotham <fg*******@SPAM.com> writes:
Chris Dollin posted:
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"?


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.

--
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.
Jun 29 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Nathan Rose | last post: by
8 posts views Thread by Mike S. Nowostawsky | last post: by
5 posts views Thread by effendi | last post: by
2 posts views Thread by Salman Khilji | last post: by
9 posts views Thread by buda | last post: by
17 posts views Thread by =?Utf-8?B?U2hhcm9u?= | last post: by
1 post views Thread by Richard Harter | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.