S
Sims
Hi,
I have some small questions that have never been any problems, (for my
compiler?), but always make me curious.
So here goes...
what does the standard sday about the 'if' statement?
for example
if i have,
/////////////////////////
const int aa = 1;
const int ab = 2;
const int ac = 4;
int someval = aa | ab | ac;
if( someval & ab )
{
// do this
}
but in the case above "someval & ab" is not true, the value is simply not
equal to 0.
Does the standard say that i am right or should i have written?
if( someval & ab != 0 )
{
// do this
}
Is my compiler wrong in accepting this?
My second question, is, if i have a structure
typedef struct
{
char a
int b
}MYSTRUCT *PMYSTRUCT
and i Read(..) a file using sizeof( MYSTRUCT ) will it make a direference if
i had declared my structure as
typedef struct
{
int b
char a
}MYSTRUCT *PMYSTRUCT
and what about a structure like
typedef struct
{
int b
char a
ANOTHERSTRUCT * B
}MYSTRUCT *PMYSTRUCT
how can i get 'sizeof' when ANOTHERSTRUCT is only a pointer? where do i get
'ANOTHERSTRUCT ' size?
where is it stored, in another segment?
Thanks for your inputs.
Sims
I have some small questions that have never been any problems, (for my
compiler?), but always make me curious.
So here goes...
what does the standard sday about the 'if' statement?
for example
if i have,
/////////////////////////
const int aa = 1;
const int ab = 2;
const int ac = 4;
int someval = aa | ab | ac;
if( someval & ab )
{
// do this
}
but in the case above "someval & ab" is not true, the value is simply not
equal to 0.
Does the standard say that i am right or should i have written?
if( someval & ab != 0 )
{
// do this
}
Is my compiler wrong in accepting this?
My second question, is, if i have a structure
typedef struct
{
char a
int b
}MYSTRUCT *PMYSTRUCT
and i Read(..) a file using sizeof( MYSTRUCT ) will it make a direference if
i had declared my structure as
typedef struct
{
int b
char a
}MYSTRUCT *PMYSTRUCT
and what about a structure like
typedef struct
{
int b
char a
ANOTHERSTRUCT * B
}MYSTRUCT *PMYSTRUCT
how can i get 'sizeof' when ANOTHERSTRUCT is only a pointer? where do i get
'ANOTHERSTRUCT ' size?
where is it stored, in another segment?
Thanks for your inputs.
Sims