Sun Studio 12 Update 1: Debugging a Program With dbx

Array Slicing Syntax for C and C++

For each dimension of an array, the full syntax of the print command to slice the array is:


print array-expression [first-expression .. last-expression : stride-expression]

where:

array-expression

Expression that should evaluate to an array or pointer type.

first-expression

First element to be printed. Defaults to 0.

last-expression

Last element to be printed. Defaults to upper bound.

stride-expression

Length of the stride (the number of elements skipped is stride-expression-1). Defaults to 1.

The first expression, last expression, and stride expression are optional expressions that should evaluate to integers.

For example:


(dbx) print arr[2..4]
arr[2..4] =
[2] = 2
[3] = 3
[4] = 4
(dbx) print arr[..2]
arr[0..2] =
[0] = 0
[1] = 1
[2] = 2

(dbx) print arr[2..6:2]
arr[2..6:2] =
[2] = 2
[4] = 4
[6] = 6