ccoboltandem

Sending data from C to COBOL on HP Tandem


I am trying to call a C function from COBOL and expecting a reply from it. I am new to this interfacing.

COBOL code:

ENTER C "ADD" USING A,B.

C code:

int ADD(int a,int b)
{
    return a+b;
}

I want to get the sum value from the C function for further processing in COBOL.


Solution

  • In COBOL

    EXTENDED-STORAGE SECTION.
    01 MYVAR EXTERNAL.
       05 DATA-01 PIC X(20).
    

    In C

     /*Add necessary includes */
     extern char MYVAR[21];
    
     void change_Cobol_Variable()
     {
       /*you can use MYVAR as normal C-variable*/
       sprintf(MYVAR, "%s","Something");
     }
    

    If it is integer declare appropriate variables as per your need :)