T
Tarique
I have the program illustrating use of Bit-Fields:
#include<stdio.h>
struct DISK_REGISTER {
unsigned ready : 1;
unsigned error_occured : 1;
unsigned disk_spinning : 1;
unsigned write_protect : 1;
unsigned head_loaded : 1;
unsigned error_code : 8;
unsigned track : 9;
unsigned sector : 5;
unsigned command : 5;
};
int main(void)
{
struct DISK_REGISTER dr;
/*...no more code here ; just trying out...*/
return 0;
}
When i run it through a debugger( Visual C++ 08)
I get the following results :
Autos:
Name Value Type
ready 0 unsigned int
error_occured 0 unsigned int
disk_spinning 1 unsigned int
write_protect 1 unsigned int
head_loaded 0 unsigned int
error_code 102 unsigned int
track 102 unsigned int
sector 19 unsigned int
command 25 unsigned int
Can anyone please explain ,what the values mean?
I know that Bit-Fields are not-portable and probably the values
generated are compiler/system specific.
Further can anyone post pointers to any archive containing some more
examples?
#include<stdio.h>
struct DISK_REGISTER {
unsigned ready : 1;
unsigned error_occured : 1;
unsigned disk_spinning : 1;
unsigned write_protect : 1;
unsigned head_loaded : 1;
unsigned error_code : 8;
unsigned track : 9;
unsigned sector : 5;
unsigned command : 5;
};
int main(void)
{
struct DISK_REGISTER dr;
/*...no more code here ; just trying out...*/
return 0;
}
When i run it through a debugger( Visual C++ 08)
I get the following results :
Autos:
Name Value Type
ready 0 unsigned int
error_occured 0 unsigned int
disk_spinning 1 unsigned int
write_protect 1 unsigned int
head_loaded 0 unsigned int
error_code 102 unsigned int
track 102 unsigned int
sector 19 unsigned int
command 25 unsigned int
Can anyone please explain ,what the values mean?
I know that Bit-Fields are not-portable and probably the values
generated are compiler/system specific.
Further can anyone post pointers to any archive containing some more
examples?