why the execution starts from main function

Answers were Sorted based on User's Feedback



why the execution starts from main function..

Answer / ravi joshi

As many of them have answered here, main is a special
function in C/C++ programs. The compiler does not care if
you have defined main or not, but linker does. If linker
finds main defined in the objects being linked, then the
address of main function is placed at the top of execution
stack. And automatically when loader loads the
program/process, the main function gets loaded at the top of
execution stack, and system starts execution using
__crtmain() which internally calls main() of the program/process

Is This Answer Correct ?    16 Yes 1 No

why the execution starts from main function..

Answer / vignesh1988i

it is the first function to be called or to be executed in
the code of the compiler.......



thank u

Is This Answer Correct ?    8 Yes 1 No

why the execution starts from main function..

Answer / vignesh1988i

their will be a program written for creating a
compiler..... so in that main() may be a first function call
for that coding written in compiler



thank u

Is This Answer Correct ?    7 Yes 0 No

why the execution starts from main function..

Answer / rahat

main is a special inbuilt function which is used to start
the execution of the program,and the compiler searches for
this function to start the execution of the program.

Is This Answer Correct ?    6 Yes 2 No

why the execution starts from main function..

Answer / vamsi

the main function receives command line arguments and so if
v pass any command line arguments as in put they have to b
taken and executed for this reason the execution starts from
main

Is This Answer Correct ?    4 Yes 1 No

why the execution starts from main function..

Answer / vrushali

The c run time system inserts some start up code before the
main function and inserts some clean up code at the end of
the program .

The operating system loads the executable of the program in
to the memory with the help of the loader and transfers the
control to theprogram .

Is This Answer Correct ?    2 Yes 1 No

why the execution starts from main function..

Answer / vrushali

If the execution of a program is required to start from a
test program e.g test (). Then we are required to change the
linker itself. As there a default program which searches for
main .

Is This Answer Correct ?    1 Yes 0 No

why the execution starts from main function..

Answer / rambo

in general _startup is handler for reset vector(0xffff in
freescale) _startup function calls main function.
if u replace main() with ur own function then the system
call ur function.

Is This Answer Correct ?    0 Yes 1 No

why the execution starts from main function..

Answer / abhradeep chatterjee

when c compiler searches for the beginning of the program,
then it looks for the main function.

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More C Interview Questions

int i; i=2; i++; if(i=4) { printf(i=4); } else { printf(i=3); } output of the program ?

15 Answers   Mascot,


WHAT IS HIGH LEVEL LANGUAGE?

2 Answers  


What is the output of the following progarm? #include<stdio.h> main( ) { int x,y=10; x=4; y=fact(x); printf(ā€œ%d\nā€,y); } unsigned int fact(int x) { return(x*fact(x-1)); } A. 24 B. 10 C. 4 D. none

2 Answers  


f=(x>y)?x:y a) f points to max of x and y b) f points to min of x and y c)error

4 Answers   HCL,


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

0 Answers   IBM,






what is difference between null and nul in c language

2 Answers  


program for following output using for loop? 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

8 Answers   Aptech, Infosys,


how to find string length wihtout using c function?

6 Answers  


Suggesting that there can be 62 seconds in a minute?

0 Answers  


Tell me is null always defined as 0(zero)?

0 Answers  


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

0 Answers   Mind Tree,


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

0 Answers  


Categories