+ 1

What is sizeof ()in c? What its use? And how its take value?

15th Jun 2020, 5:54 AM
Sumit Chand
3 Answers
+ 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))
16th Jun 2020, 1:57 AM
Gen2oo
Gen2oo - avatar
0
It returns number of bytes allocated for the datatype
15th Jun 2020, 6:22 AM
uday kiran
uday kiran - avatar
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.
15th Jun 2020, 8:14 AM
Anubhav Mattoo
Anubhav Mattoo - avatar