What’s sizeof(size_t) on 32-bit vs the various 64-bit data models?

size_t is defined by the C standard to be the unsigned integer return type of the sizeof operator (C99 6.3.5.4.4), and the argument of malloc and friends (C99 7.20.3.3 etc). The actual range is set such that the maximum (SIZE_MAX) is at least 65535 (C99 7.18.3.2). However, this doesn’t let us determine sizeof(size_t). The implementation … Read more

Sizeof arrays and pointers

“…after all it’s just a pointer…”? No. Array is not a pointer. Array is an array object: a solid continuous block of memory that stores the array elements, no pointers of any kind involved. In your case array has 6 elements of size 4 each. That is why your sizeof evaluates to 24. The common … Read more

sizeof Java object [duplicate]

The question is not meaningful, at least not without further context. The notion of “size” in Java is only reasonably well defined for primitives: A byte is 8 bit (unsurprisingly) an int is 32 bit, a long 64bit, etc. (see e.g. http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html for a full list). For object instances, it’s more complicated, because: Object instances … Read more

Implementation of sizeof operator

The result of pointer subtraction is in elements and not in bytes. Thus the first expression evaluates to 1 by definition. This aside, you really ought to use parentheses in macros: #define my_sizeof(x) ((&x + 1) – &x) #define my_sizeof(x) ((char *)(&x + 1) – (char *)&x) Otherwise attempting to use my_sizeof() in an expression … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)