The following example shows how C functions can be accessed from a COBOL program:
$set rtncode-size"4" working-storage section. 01 str. 03 str-text pic x(10). 03 filler pic x value x"00". * Null terminate string for C function 01 counter pic 9(8) comp-5 value zero. procedure division. call-c section. call "cfunc" using str, counter if return-code not = zero * RETURN-CODE set from return () in C display "ERROR" else display "OK" end-if stop run. ------------------------------------------------
cfunc (st, c) char *st; int *c; { ... return(0); }