You can construct and manipulate null-terminated strings (for example, strings that are passed to or from a C program) by various mechanisms.
For example, you can:
MOVE 0 TO char-count
INSPECT source-field TALLYING char-count
FOR CHARACTERS
BEFORE X“00”WORKING-STORAGE SECTION.
01 source-field PIC X(1001).
01 char-count COMP-5 PIC 9(4).
01 target-area.
02 individual-char OCCURS 1 TO 1000 TIMES DEPENDING ON char-count
PIC X.
. . .
PROCEDURE DIVISION.
UNSTRING source-field DELIMITED BY X“00”
INTO target-area
COUNT IN char-count
ON OVERFLOW
DISPLAY “source not null terminated or target too short”
END-UNSTRINGExample: null-terminated strings
related tasks
Handling null-terminated strings
related references
Alphanumeric literals
(COBOL for Windows Language Reference)