3.5.2. Reading Values From Arrays
array_name[index_expression]statement as an element in a mathematical expression. For example:
Example 3.13. Using Array Values in Simple Computations
delta = gettimeofday_s() - foo[tid()]
foowas built using the construct in Example 3.12, “Associating Timestamps to Process Names” (from Section 3.5.1, “Assigning an Associated Value”). This sets a timestamp that will serve as a reference point, to be used in computing for
deltaby subtracting the associated value of the key
tid()from the current
gettimeofday_s(). The construct does this by reading the value of
tid()from the array. This particular construct is useful for determining the time between two events, such as the start and completion of a read operation.
index_expressioncannot find the unique key, it returns a value of 0 (for numerical operations, such as Example 3.13, “Using Array Values in Simple Computations”) or a null/empty string value (for string operations) by default.