Under z/OS® batch

Copy the IBM-supplied sample program and header file into your data set. For example, if your user prefix is PETE, store the sample program CCNUBRC in PETE.TEST.C(CCNUBRC), and the header file CCNUBRH in PETE.TESTHDR.H(CCNUBRH). You can use the IBM-supplied cataloged procedure CBCCBG to compile, bind, and run the source code as follows:
Figure 1. JCL to compile, bind, and run the example program using the CBCCBG procedure
//*
//* COMPILE, BIND AND RUN
//*
//DOCLG    EXEC  CBCCBG,
//         INFILE='PETE.TEST.C(CCNUBRC)',
//         CPARM='OPTFILE(DD:CCOPT)'
//COMPILE.CCOPT DD *
          LSEARCH('PETE.TESTHDR.H')
          SEARCH('CEE.SCEEH.+','CBC.SCLBH.+')
/*
//* ENTER A DATE IN THE FORM YYYY/MM/DD
//GO.SYSIN DD *
  1997/10/19
/*

In Figure 1, the LSEARCH statement describes where to find the user include files, and the SEARCH statement describes where to find the system include files. The GO.SYSIN statement indicates that the input that follows it is given for the execution of the program.

XPLINK under z/OS batch

The following example shows how to compile, bind, and run a program with XPLINK using the CBCXCBG procedure:

Figure 2. JCL to compile, bind, and run the example program with XPLINK using the CBCXCBG procedure
//*
//* COMPILE, BIND AND RUN
//*
//DOCLG    EXEC  CBCXCBG,
//         INFILE='PETE.TEST.C(CCNUBRC)',
//         CPARM='OPTFILE(DD:CCOPT)'
//COMPILE.CCOPT DD *
          LSEARCH('PETE.TESTHDR.H')
          SEARCH('CEE.SCEEH.+','CBC.SCLBH.+')
/*
//* ENTER A DATE IN THE FORM YYYY/MM/DD
//GO.SYSIN DD *
  1997/10/19
/*

For more information on compiling, binding, and running, see Compiling, Binding z/OS XL C/C++ programs, and Running a C or C++ application.