Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Array elements

Reply
Thread Tools

Array elements

 
 
Kumar
Guest
Posts: n/a
 
      06-29-2006
How should I declare the array elements being half word?
and the array elements of the type byte in C??

Please help


Kumar

 
Reply With Quote
 
 
 
 
Chris Dollin
Guest
Posts: n/a
 
      06-29-2006
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/

 
Reply With Quote
 
 
 
 
Frederick Gotham
Guest
Posts: n/a
 
      06-29-2006
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
 
Reply With Quote
 
Chris Dollin
Guest
Posts: n/a
 
      06-29-2006
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/

 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      06-29-2006
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
 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      06-29-2006
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.

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      06-29-2006
Frederick Gotham <> 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) kst- <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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to access the elements in an array with array[1][0] Arti Singh Ruby 2 07-26-2010 04:42 PM
initialize an array of elements that contain another array wenmang@yahoo.com C Programming 10 08-02-2006 04:52 PM
XML elements to JavaScript Array elements Conversion P XML 1 07-07-2006 09:08 PM
searching elements of an array within another array diffused Java 9 08-01-2004 10:09 AM
Find if elements of one array are present in the other and return a boolean array Shalini C++ 2 01-09-2004 06:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57