Re: why is this result ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 19, 2013 3:00 AM, "horseriver" wrote:
>
> On Fri, Jan 18, 2013 at 03:27:25PM +0000, Jonathan Wakely wrote:
> > >>   printf("size of A is %d \n",sizeof(A));
> > >>   //printf("size of B is %d \n",sizeof(B));
> >
> > Careful, you are using %d which expects an int but sizeof gives a size_t
> Thanks!
> I have not understand what you mean ? size_t is a unsigned int ,I think  it does not matter here

It's quite easy to understand.

Your printf should be passed an int

The sizeof operator does not give you an int. On my platform it gives
a 64-bit integer. Even on your platform it does not give you an int,
unsigned int is not int.

The code is not portable, so you should be careful about writing and
using such code. If you compile with warnings you will get a warning
about it. It's your code so you can choose to ignore it if you think
you know better than the compiler. But you should be careful.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux