Posts

VARIOUS METHODS TO FIND SIZE OF WITHOUT USING sizeof() OPERATOR

Image
Sizeof   is a much used operator in the  C programming language . It is a compile time unary operator which can be used to compute the size of its operand.  The result of sizeof is of unsigned integral type which is usually denoted by size_t. sizeof can be applied to any data-type, including primitive types such as integer and floating-point types, pointer types, or compound datatypes such as Structure, union etc. METHODS TO FIND SIZE OF  WITHOUT USING sizeof() OPERATOR : Program to find the size of a variable  using  P ointers 1 2 3 4 5 6 7 8 9 10 #include<stdio.h> int main (void ) {      int * ptr ;           ptr ++ ;           printf ( "Size of ptr = %d\n" , ptr ) ;      return 0 ; } Program to implement your  own sizeof(),   O perator 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include<stdio.h> int my_sizeof ( var ) {      return ( ( char * ) ( & va