i think the output is return type of main();

On Sep 7, 9:19 am, rahul vatsa <[email protected]> wrote:
> the expression to sizeof is analyzed @compile time to determine its type.
> so, when u do sizeof(main()) in main( ), it doesn't call main again, it just
> gets the type of the function.
> if you declare main as  void main( ) o/p will be 1
> if its int main( ) o/p 4
>
> if you just write main in an expression, usually it implicitly converts to
> corresponding function pointer, but in case of being argument of sizeof,
> compiler doesn't do this conversion. so
> sizeof(main) will also be 1 or 4 depending on the prototype of main.
>
>
>
>
>
>
>
> On Tue, Sep 6, 2011 at 11:25 PM, rahul vatsa <[email protected]> wrote:
> >  sizeof(void)  ->  1
>
> > void is a datatype, though u cant create obj of void type, then also it hs
> > to hs a size, so it hs been given the minimal sz i.e 1.
>
> > On Tue, Sep 6, 2011 at 3:13 PM, Kunal Patil <[email protected]> wrote:
>
> >> @siddharam suresh: sizeof(void) is an prohibited operation. So your code
> >> would result in compile time error.
>
> >> On Tue, Sep 6, 2011 at 11:47 PM, siddharam suresh <
> >> [email protected]> wrote:
>
> >>> my guess,
> >>> sizeof() takes only the declaration properties not the definition
> >>> properties(that means it wont call the function)
>
> >>> *#include<stdio.h>*
> >>> *void c(); *
> >>> *int main()*
> >>> *{*
> >>> *printf("%d",sizeof(c()));*
> >>> *}*
> >>> *void c()*
> >>> *{*
> >>> *printf("c"); *
> >>> *}*
> >>> *o/p:*
> >>> *1*
>
> >>> Thank you,
> >>> Sid.
>
> >>> On Tue, Sep 6, 2011 at 11:41 PM, siddharam suresh <
> >>> [email protected]> wrote:
>
> >>>> its size of return type, but why the above program not showing
> >>>> segmentation fault?
> >>>> Thank you,
> >>>> Sid.
>
> >>>> On Tue, Sep 6, 2011 at 11:34 PM, ankush garg <[email protected]>wrote:
>
> >>>>> better contact AKSHAY CHADHA .. the person is quite good at c and
> >>>>> algos.... currently placed in MICROSOFT..
> >>>>> [email protected]
> >>>>> 9899466888
>
> >>>>> --
> >>>>> You received this message because you are subscribed to the Google
> >>>>> Groups "Algorithm Geeks" group.
> >>>>> To post to this group, send email to [email protected].
> >>>>> To unsubscribe from this group, send email to
> >>>>> [email protected].
> >>>>> For more options, visit this group at
> >>>>>http://groups.google.com/group/algogeeks?hl=en.
>
> >>>  --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected].
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/algogeeks?hl=en.
>
> >>  --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.

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

Reply via email to