You are here:

C/c programming

Advertisement


Question
hello sir.i have a problem
main()
{
printf("%u",main);
}
when i m compiling it,its giving an error- Cannot take address of 'main' in function main()
but from the book i took the question,says that it should return the starting address of main,as the name of the function is the pointer to it.can you plz explain what's correct and the logic behind it..thanks


Answer
Hello Prachi

You are correct. The program should print out the address of the main function. I have tried it with the Microsoft compiler and the Gnu compiler and it works as expected. I would say the compiler you are using is not up to the standard. This is not unusual for older compilers. Which compiler are you using?

Best regards.
Zlatko

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.