>> sizeof(main()) == sizeof(int) because main return integer.
But main isn't invoked, sizeof does all thing at compile time.

On Wed, Jul 27, 2011 at 9:27 PM, Charlotte Swazki
<charlotteswa...@yahoo.fr>wrote:

> No. it's wrong.
>
> sizeof(main()) == sizeof(int) because main return integer.
>
> i
>
>
>
> ----- Mail original -----
> De : Vishal Thanki <vishaltha...@gmail.com>
> À : algogeeks@googlegroups.com
> Cc :
> Envoyé le : Mercredi 27 Juillet 2011 15h45
> Objet : Re: [algogeeks] sizeof() question.
>
> I am not sure about the first question, but if you use sizeof(main()),
> it gives the ans 4.
> vishal@ubuntu:~/progs/c\ 09:12:57 PM >$ cat alg.c
> #include<stdio.h>
> int main()
> {
>     printf("%d\n",sizeof(main()));
> return 0;
> }
> vishal@ubuntu:~/progs/c\ 09:13:00 PM >$ gcc alg.c
> vishal@ubuntu:~/progs/c\ 09:13:02 PM >$ ./a.out
> 4
> vishal@ubuntu:~/progs/c\ 09:13:03 PM >$
>
>
> The reason why it doesn't overflow is because sizeof() operator
> calculates the size at compile time, and it doesn't really invoke
> main().
>
> Vishal
>
> On Wed, Jul 27, 2011 at 9:02 PM, Charlotte Swazki
> <charlotteswa...@yahoo.fr> wrote:
> > Hi there,
> >
> > I have two questions,
> >
> > Why sizeof(main) == 1 ? (sizeof(func) == 1).
> > Not 4 bytes ?.sizeof(void) == 1 too.
> >
> >
> > And this code doesn't stackoverflow ?
> > int main() {
> >
> >  sizeof(main());
> > }
> >
> >
> >
> > Thanks,
> >
> > --
> > 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.
> >
> >
>
> --
> 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.
>
> --
> 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.
>
>

-- 
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