Prism 6.0 User's Guide

Using C Arrays in Expressions

Prism handles arrays slightly differently from the way C handles them.

In a C program, if you have the declaration

int a[10];

and you use a in an expression, the type of a converts from "array of ints" to "pointer to int". Following the rules of C, therefore, a Prism command like

(prism) print a + 2

should print a hexadecimal pointer value. Instead, it prints two more than each element of a (that is, a[0] + 2, a[1] + 2, etc.). This allows you to do array operations and use visualizers on C arrays in Prism. (The print command and visualizers are discussed in Chapter 5, Visualizing Data.)

To get the C behavior, issue the command as follows:

(prism) print &a + 2