473,657 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1556
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_Keit h) 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2116
by: Nathan Rose | last post by:
Here's my problem. I am reading from a text file using this: if (!file_exists($file)) { echo "Don't exist\n"; return false; } $fd = @fopen($file, 'r'); if (!is_resource($fd))
8
10217
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1 = new Array(); GridArrayName1 = new Array ('test-value'); GridArrayName1 = GridArrayName1...
5
6371
by: effendi | last post by:
I wrote a simple script to remove an element of an array but I don't think this is the best way to go about it. I have a list of about five elements seperated by ";" I split the array using array.split(";") command and proceeded to update the elemment by assigning the null value to the arrayindex array=""
35
6621
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
2
2090
by: Salman Khilji | last post by:
After reading all the FAQs, I cannot solve the following problem: I have a pointer of type double. I am supposed to 1) Allocate memory for it assuming that the pointer will be pointing to a multi-dimensional array whose dimensions will be specified at run-time. 2) Set the individual elements of the array using pointer-arithmetic.
4
5629
by: Jens Mittag | last post by:
Hi! In my code, I have an array of a structure, which I want to save to a binary file. When the array is just created, everything works fine, but when I change contents of the array, saving results in a file, which doesn't hold the information of the changed array anymore. I dont know why. Here is the code: /*
9
2612
by: buda | last post by:
Hi, I've been wondering for a while now (and always forgot to ask :) what is the exact quote from the Standard that forbids the use of (&array) (when x >= number_of_columns) as stated in the FAQ 6.19 (http://www.eskimo.com/~scs/C-faq/q6.19.html). Thanks.
9
2309
by: Luke Wu | last post by:
Hello, I'm having some problems understanding 2 dimensional arrays. My problem relates to the following code: #include <stdio.h> #define M 3 #define N 3
17
7239
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need to show the array data to the end user. Can I do that? How?
1
4907
by: Richard Harter | last post by:
On Fri, 27 Jun 2008 09:28:56 -0700 (PDT), pereges <Broli00@gmail.comwrote: There are some obvious questions that should be asked, e.g., is the contents of your array already sorted as your example implies. If they are then all you need to do is find the element at index k = n/2 and then increase k until you find an element that differs from A. Then k is the number of left children and n-k is the number of right children. (Fencepost...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.