true or false

the execution of program starts at main.
plz anser
Under the cstdlib on my linux machine, the function main is called by the function _start, so execution must begin before main is called.
(posting from iPhone in the middle of an exam)
I would say false.
@Disch i am @india and no exam (in my knowledge can be happening at 7:27 pm IST..... plz share your views i am confused
What do you mean with "execution"? The execution of the PE/ELF binary format or the interpretation of your own code?

What came first? The hunger or the food?
closed account (1vRz3TCk)
It is implementor defined wether or not a program needs a main() function in a free standing environment, so it must be false ... but may be true depending on what you are actually asking.
Last edited on
According to the C++ Standard "A program shall contain a global function called main, which is the designated start of the program." So if your C++ program is not executed in free-standing environment you may say that main is the start of the program. All other code in the executable module is not your program and you may know nothing about it.
Last edited on
> the execution of program starts at main.

Depends on your perspective.

1
2
3
4
5
6
7
#include <iostream>

int g = ( (std::cout << "hello world\n" ), 0 ) ;

int main()
{
}


We could say (re a hosted environment)any of these:

1. The execution of program starts with the creation of a new process/task
2. The execution of program starts with the loader loading the program into an address space
3. The execution of program starts with the execution of constructors for objects of namespace scope with static storage duration.
4. The execution of program starts with main(); and main() implicitly begins with the execution of constructors for objects of namespace scope with static storage duration.
5. ...
Aren't you glad you asked??? 8^)

Bottom line: If you're a beginner programmer, your teacher expects TRUE. If you're advanced your teacher expects FALSE (but would probably want you explain the subtleties of that answer).

I would write in the answer Stoopid Question. But that's just me...
Topic archived. No new replies allowed.