ILE C/C++ Programmer's Guide

Displaying Character Arrays

The following example shows the usage of the ':c' syntax to format an expression as characters. The array must be dereferenced by the '*' operator. If the * operator is not entered, the array will be displayed as a space pointer. If the dereferencing operator is used, but the ':c' is not appended to the expression, only the first array element is displayed. The default length of the display is 1.

  1. While in a debug session, type DSPMODSRC. The Display Module Source display is shown.
  2. Set a breakpoint at line 6.
  3. Press F12(Resume) to leave the Display Module Source Display.
  4. Call the program. The program stops at the breakpoint at line 6.
  5. Enter eval *array1: c 11 on the debug command line, as shown:
    +--------------------------------------------------------------------------------+
    |                              Display Module Source                             |
    | Program:   TEST3          Library:   DEBUG          Module:   MAIN             |
    |      1  #include <string.h>                                                    |
    |      2  char array1 [11];                                                      |
    |      3  int i;                                                                 |
    |      4  int main(){                                                            |
    |      5    strcpy(array1,"0123456789");                                         |
    |      6    i = 0;                                                               |
    |      7    return 0;                                                            |
    |      8  }                                                                      |
    |                                                                     Bottom     |
    | Debug . . .  eval *array1: c 11________________________________________        |
    | ________________________________________________________________________       |
    | F3=Exit program   F6=Add/Clear breakpoint   F10=Step   F11=Display variable    |
    | F12=Resume       F17=Watch variable   F18=Work with watch  F24=More keys       |
    +--------------------------------------------------------------------------------+

    The following illustrates displaying 11 characters, including a null character. The null character appears as a blank.

    +--------------------------------------------------------------------------------+
    |                              Display Module Source                             |
    | Program:   TEST3          Library:   DEBUG          Module:   MAIN             |
    |      1  #include <string.h>                                                    |
    |      2  char array1 [11];                                                      |
    |      3  int i;                                                                 |
    |      4  int main(){                                                            |
    |      5    strcpy(array1,"0123456789");                                         |
    |      6     i = 0;                                                              |
    |      7    return 0;                                                            |
    |      8  }                                                                      |
    |                                                                     Bottom     |
    | Debug . . .  ___________________________________________________________       |
    | ________________________________________________________________________       |
    | F3=Exit program   F6=Add/Clear breakpoint   F10=Step   F11=Display variable    |
    | F12=Resume       F17=Watch variable   F18=Work with watch  F24=More keys       |
    | *array1: c 11 = '0123456789 '                                            ...   |
    +--------------------------------------------------------------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents ]