The following example shows how to initialize (and close down) the COBOL environment from a C main(), so that a COBOL program can be called:
main(int argv, char *argv) { cobinit(); /* Initialize COBOL environment */ cobcall("cobep", 0, NULL); /* Call a COBOL program */ cobtidy(); /* Close down COBOL environment */ return(0); )
Comments:
You must call cobinit() before calling a COBOL program if the main program is not written in COBOL or the programs in the application are linked with the static COBOL run-time system .
If you do not, you might receive an initialization error when you enter your COBOL code.
On some platforms, the COBOL environment is initialized when the COBOL run-time system is loaded (for example, at process startup).
If the COBOL environment has already been initialized then cobinit() returns successfully.
This function returns 0 on success.