473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Bit fields

Hi,
Can anyone please explain the difference between the following
sample1 and sample2 structures??

struct sample1{
unsigned int a:4;
unsigned int b:4;
};

struct sample2{
unsigned int a:4,
b:4;
};

Mar 6 '07 #1
5 1679
both are same... there is no difference....
just two different methods of declaring a bit field structure..
Sweta wrote:
Hi,
Can anyone please explain the difference between the following
sample1 and sample2 structures??

struct sample1{
unsigned int a:4;
unsigned int b:4;
};

struct sample2{
unsigned int a:4,
b:4;
};
Mar 6 '07 #2
Can anybody please explain
which one of these is preferred way of declaring and why??

Thanks,
Sweta
On Mar 6, 4:04 pm, "akhil.mi...@gmail.com" <akhil.mi...@gmail.com>
wrote:
both are same... there is no difference....
just two different methods of declaring a bit field structure..

Sweta wrote:
Hi,
Can anyone please explain the difference between the following
sample1 and sample2 structures??
struct sample1{
unsigned int a:4;
unsigned int b:4;
};
struct sample2{
unsigned int a:4,
b:4;
};- Hide quoted text -

- Show quoted text -

Mar 6 '07 #3
Sweta wrote:

Please don't top-post. Your reply belongs after or interspersed with
the relevant portions of the article you're quoting.
[fixed]
On Mar 6, 4:04 pm, "akhil.mi...@gmail.com" <akhil.mi...@gmail.comwrote:
Sweta wrote:
>
Hi,
Can anyone please explain the difference between the following
sample1 and sample2 structures??
struct sample1{
unsigned int a:4;
unsigned int b:4;
};
struct sample2{
unsigned int a:4,
b:4;
};

both are same... there is no difference....
just two different methods of declaring a bit field structure..

Can anybody please explain
which one of these is preferred way of declaring and why??
Well, I personally prefer the first one, since it's, IMHO, far more
readable.

Mar 6 '07 #4
Does this even compile? The way I learned it, there was no type between
unsigned and the name since it is a series of n bits not a machine-sized
integer.
---Matthew Hicks

Hi,
Can anyone please explain the difference between the following
sample1 and sample2 structures??
struct sample1{
unsigned int a:4;
unsigned int b:4;
};
struct sample2{
unsigned int a:4,
b:4;
};

Mar 6 '07 #5
Matthew Hicks <md******@uiuc.eduwrites:
>Can anyone please explain the difference between the following
sample1 and sample2 structures??
struct sample1{
unsigned int a:4;
unsigned int b:4;
};
struct sample2{
unsigned int a:4,
b:4;
};

Does this even compile? The way I learned it, there was no type
between unsigned and the name since it is a series of n bits not a
machine-sized integer.
Please don't top-post; I've fixed it here. Read the following:
http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

I think you're saying that it should be "unsigned a:4;" rather than
"unsigned int a:4;". That's incorrect; both are equally valid. There
are a variety of ways to refer to the predefined integer types; the
names "unsigned int", "unsigned", and even "int unsigned" all mean
exactly the same thing. (I don't recommend using "int unsigned",
though; it's legal due to a quirk in the grammar, but it's confusing.)

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Cowan | last post by:
Hi I am trying to create a CSV file with some fields in double quotes ("). I am not having any luck. This is what I want; "8684","COSTING","000010001","REG",X4,15.00, ,14,0,14,9,6 I am...
0
by: bill mahoney | last post by:
I have access 2k and I have 2 tables. One is a 7X6 table representing a month with zeroes padding the fields where no day exist. For example February 2003 0 0 0 0 0 0 1 2 3 4 5 6 7 ...
4
by: Melissa | last post by:
I have a frontend file named CustomerApp and backend file named CustomerData. CustomerApp is at C:\Customer Database and CustomerData is at S:\Customer Database. Could someone help me with the code...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
2
by: Darryl Kerkeslager | last post by:
As the subject above hopefully makes clear, I want to do several reports, "with lots of fields not otherwise in database". These reports also have variable-length text. I have defined the...
0
by: Proteus | last post by:
Hi, I'm using access 97 on windows 98. I have table with 162 fields in it. I need to withdraw this information in a (totals) query with 164 fields (162 "avg" fields and 2 "count" fields). When I...
5
by: Genboy | last post by:
My "VIS" Website, which is a C# site created in VS.NET, Framework 1.1, is no longer compiling for me via the command line. As I have done 600 times in the last year and a half, I can compile to...
4
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
Hey, Well, I have a Problem. I have designed a table which has few fields which are being declared in the database of type .... char of length 10. and other fields with varchar 50 and...
9
by: sean.scanlon | last post by:
can someone help understand how i can could access a struct field dymanically like: foo->fields ? when i try to compile this i get the following error: 'struct pwd' has no member named 'fields'...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.