[algogeeks] sizrof imolementation

2010-05-31 Thread debajyotisarma
This is not about algorithms,but related to C programming. How to implement sizeof operator? macro for this #define my_sizeof(a) (char*)(a+1)-(char*)a this works fine of variables int a; printf(%d,my_sizeof(a)); //or even for user defined structures but it will not work for

Re: [algogeeks] sizrof imolementation

2010-05-31 Thread jaladhi dave
As you already mentioned sizeof is an operator and not a lib fn. Which means it will be evaluated/code for it will be replaced at compile time rather than during execution. It will follow the following grammar, unary_operator: sizeof , and others sizeof: ( unary expression | type_name) and so