Calling 'C' Routines



Programmers who need to call 'C' routines (either directly or in a DLL) soon realise that COBOL's view of an alphanumeric string differs to that of 'C'. 'C' will expect to see a 'null' character (hex '00') at the end of the string, that's how it knows where the end is! Fortunately there's an easy way for us to do this:

INSPECT MY-STRING REPLACING TRAILING SPACES BY LOW-VALUES.

Provided there's at least one trailing space you're all done. If you are concerned that there may not be a trailing space then you should also declare the item as:

01 MY-STRING.
  03 FILLER     PIC X(25).
  03 FILLER     PIC X VALUE X'00'.

Now you're absolutely sure that there will be a trailing null in all cases.

Your Session will expire in 90 minutes
Notification will be shown in:
600 seconds