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

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 Pointers



Program to implement your own sizeof(), Operator

Program to find the size of a variable using Macro

        METHOD 2:

1
2
3
4
5
6
7
8
9
#include<stdio.h>
#define MYSIZEOF(X) ((X*)0 +1)
int main(void)
{
    printf("%ld", MYSIZEOF(int));
    return 0;
}

Program to find the size of a variable using an Array

Thanks for reading Guys. If you have any doubt, please write the comment below. Keep Learning. Happy coding 😉
Connect on linkedin by clicking ->  MUNISH BHARDWAJ

Comments

Post a Comment