In said:
I know c run time term, and also I use c run time lib. But I still confused
about what's the c run time? Is there run time environment created before
loading the c/c++ program?
It is created before executing the main function of the C program.
If there is, what's its functionality ?
At the very least, it must create the argv array and call main() in such
a way that returning from its initial invocation has the same effect as
calling exit() with its return value. This can be trivially achieved
with:
exit(main(argc, argv));
If the compiler relies on the CPU being initialised in a certain way
(e.g. the FP rounding mode, denormal handling or FP exception handling),
this initialisation must also take place before main() is called.
Some of the library functions may also require certain initialisations
to be performed before main() is executed (e.g. the setup of the malloc
and friends arena).
When people talk about the C run time, they usually refer to the C run
time support provided by the implementation, i.e. the startup module doing
the jobs described above and the libraries available to a C program.
The C run time environment is a more complex concept, depending on how the
implementation works: by compiling C into machine code or by interpreting
it. In the former case, the C run time environment consists of the C run
time support and the OS under which the program runs. In the latter,
there is an additional software layer between the C program and the OS,
whose existence is needed because usual computers cannot execute C code
directly.
Dan