here is the generalized way

#include<stdio.h>
#define SIZEOF(var) (size_t)(&var+1) - (size_t)(&var)
main()
{
double x;
printf("The size of x is %d\n",SIZEOF(x));
return 0;
}

On Fri, Jun 24, 2011 at 1:35 AM, Anika Jain <anika.jai...@gmail.com> wrote:

> #include<stdio.h>
>
> int main()
> {
>     char x='9',size=0,count;
>     while(x)
>     {
>         x = x<<1;
>         count++;
>         if((count=count%8)==0)
>         {
>             size++;
>         }
>     }
>     printf("%d\n",size);
>     return 0;
> }
>
> this code i tried to find size of a variable without using sizeof.. but its
> only for ints and chars... not general.. does anybody hava a general
> answer??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
  best wishes!!
Vaibhav Shukla
    DU-MCA

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to