Re: Pointer to int, implicit conversion
On Nov 21, 6:27 pm, James Kuyper <jameskuy...@ve rizon.netwrote:
the 64 pit machine
This is the output i got from a program which was written for size of
int, char, long, pointer etc
sizeof char = 1 , shortint = 2 , int 4 , long = 8 , pointer = 8
There is a difference in int and pointer size
>
As far as I know, the only issue with if(p) is whether or not the
programmer correctly understands that it is identical in meaning to
if(p!=0). I don't see how that depends upon whether the machine is 32
bits or 64 bits.
>
would there be any probablity to get unexpected result here, at any
point of time??
does our intention match with the compiler's ??
does the compiler checks whether the 64 bit value is zero or the 32
bit value is zero??
should the compiler see 'p' as pointer or an integer.Does this really
make any difference??
>
is the output dependend upon the mercy of compiler??
i am thinking about the loss of few bytes which would make difference
On Nov 21, 6:27 pm, James Kuyper <jameskuy...@ve rizon.netwrote:
Rakesh UV wrote:
...
>
>
>
On Nov 21, 9:36 am, James Kuyper <jameskuy...@ve rizon.netwrote:
Tomás Ó hÉilidhe wrote:
> So basically, the conditionals take the value, regardless of its
>type, and return false if it's zero (including a null pointer), otherwise
>type, and return false if it's zero (including a null pointer), otherwise
Conditionals do not return false (or true); they result in one part of
the code or another being executed. They do this based upon whether or
not the conditional expression compares equal to 0. That's not the same
as saying it's the same as 0. An expression can be zero only if it has
arithmetic type. Pointers do not have an arithmetic type, so it's not
meaningful to say that they are 0, but because of the rules for null
pointer constants, pointers compare equal to zero when they are null.
the code or another being executed. They do this based upon whether or
not the conditional expression compares equal to 0. That's not the same
as saying it's the same as 0. An expression can be zero only if it has
arithmetic type. Pointers do not have an arithmetic type, so it's not
meaningful to say that they are 0, but because of the rules for null
pointer constants, pointers compare equal to zero when they are null.
If You are working in a 64 bit machine then it would make a difference
Explain, please?
>
>
int, char, long, pointer etc
sizeof char = 1 , shortint = 2 , int 4 , long = 8 , pointer = 8
There is a difference in int and pointer size
otherwise if(p) doesn't have any issue in 32 bit machine
As far as I know, the only issue with if(p) is whether or not the
programmer correctly understands that it is identical in meaning to
if(p!=0). I don't see how that depends upon whether the machine is 32
bits or 64 bits.
>
point of time??
If we really want to use a language efficiently and safely, Then we
should
try to express our intension much clearly and specifically in C
language.
should
try to express our intension much clearly and specifically in C
language.
>
If(p) seems perfectly clear to me.
>
If(p) seems perfectly clear to me.
>
bit value is zero??
should the compiler see 'p' as pointer or an integer.Does this really
make any difference??
instead of allowing the compiler to assume thing, this a very bad
Practice.
Practice.
What assumption are you talking about?
Comment