main( ) procedure to allow library initialization code to run.
"C" and extern keywords.
Here is the basic syntax:
extern "C" funName( paramlist ) {
... }
Here is an example:
extern "C" int askForInteger( ) {
cout << "Please enter an integer:";
// ...
}
Rather than modifying every function definition, it's easier to group multiple function prototypes inside a block.
Then you can omit extern and "C" from the function implementations:
extern "C" {
int askForInteger( );
int showInt( int value, unsigned outWidth );
etc.
}
|
“I’m not arguing, I’m just explaining why I’m right.” ― Unknown |