For gcc there's a non-standard solution. Declare the function with __attribute__((constructor)) (note the double parentheses).
Like this:
void init(void) __attribute__ ((constructor));
void init(void) {
// your code goes here
}
Starting with gcc 4.3 there's even a possibility to assign a priority to the "constructor". See http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html for details.
main()
Technically, the first function executed is the library entry point, but that does not count from a programmer's perspective.
Every C plus plus program that is a main program must have the function 'main'.
No. Neither C nor C++ are interpreted. Both need to be compiled and linked to produce highly-optimised machine code, which is then executed.
There is no such thing. You probably meant the main function. The main function is the only function that is required as it serves as the entry point of the program.
Anything declared outside of a function is global.
Abstraction is a process by which higher concepts are derived from the usage and classification of literal ("real" or "concrete") concepts, first principles and/or other abstractions.
It is the first function that gets called when the program is executed.
Every C plus plus program that is a main program must have the function 'main'.
No. Neither C nor C++ are interpreted. Both need to be compiled and linked to produce highly-optimised machine code, which is then executed.
There is no such thing. You probably meant the main function. The main function is the only function that is required as it serves as the entry point of the program.
Anything declared outside of a function is global.
Functions are very important in C++, as you can't write the simplest program to print hello without using a function. Overall you can say that function are building blocks of a C++ program. Functions can also be defined by the programmer to reduce program size.
I don't think its possible. Every C++ program must at least have the main function.
Abstraction is a process by which higher concepts are derived from the usage and classification of literal ("real" or "concrete") concepts, first principles and/or other abstractions.
By learning how to program on C+.
In C and C++, as well as in many (all?) languages, a function can be called from more than one place in a program. That's the purpose of functions - to encapsulate pieces of code that are needed in more than one place in the program.
If you are talking about the program executing, but the output screen being displayed for a flash and then disappearing, I suggest adding getch() or getchar() function at the end of your main function. This will make sure that the output screen waits for you to press a character before the program terminates.
Multi-function simply means more than one function. Every program must have at least one function, the main function (the entry point of the application), and although you can write an entire program using just this one function, breaking the program down into several smaller functions makes the code easier to read and maintain. A major advantage of multi-function programming is that functions can be called as often as required -- there is no need to write the same piece of code over and over again.