&main

1 view
Skip to first unread message

TheSuyog

unread,
Aug 10, 2010, 11:54:06 AM8/10/10
to Knowledge Test
Hello everybody!

Whats supposed to happen if we run this code:

void main()
{
cout<<&main;
}

Try to answer this without running...

SONALI-

unread,
Aug 10, 2010, 12:00:06 PM8/10/10
to knowledge-...@googlegroups.com
some particular addresss where the main function store in memory..hope it is correct..lemme knw

TheSuyog

unread,
Aug 10, 2010, 12:03:37 PM8/10/10
to Knowledge Test
will let u know once most of (active) members have answerred it....

Ravina soni

unread,
Aug 10, 2010, 12:42:31 PM8/10/10
to knowledge-...@googlegroups.com

It'll nt run give a error
nt nly for main even for any fun like cout<<&fun is nt the right way to print it's address 
cout<<(void*)main;
cout<<(void*)fun; 
print the address of funtion

I think function name is reference, contaning address of function

SONALI-

unread,
Aug 10, 2010, 12:47:19 PM8/10/10
to knowledge-...@googlegroups.com
yup function main contain address as every instuction and evry function of program starts at particular address..
so if we us the pointer operator '&' (called "address of " sign) returns the address of the main function..:)
Reply all
Reply to author
Forward
0 new messages