+ 1
What is sizeof ()in c? What its use? And how its take value?
3 Respostas
+ 2
sizeof() is evaluated at runtime for variable length arrays (introduced in C99) but that's the one and only exception. Most other cases it's a compile-time operator and the operand is not evaluated at all, which is you why you can get the size of members from a struct through a null pointer dereference (which would not be possible if the operand was evaluated).
Example:
#define MEMB_SIZEOF(type, memb) (sizeof(((type *)0)->memb))
0
It returns number of bytes allocated for the datatype
0
It is the really heavily overloaded operator of C which calculates the total size of an identifier in 'bytes'. Each Identifier in C has it's own memory allocation scheme and this operator returns the size of this memory allocation for each scheme, static or dynamic.
Remember : It is a heavily overloaded operator in C and hence is also immutable.
Operator Overloading is not exclusive to Object Oriented Paradigm. Functional Paradigm also supports Operator Overloading.