what are triangular arrays and how are they linearized?

A triangular array is not builtin type. It's a program (or may be application domain artifact). For example:

aaaa - row 0
 bbb  - row 1
  cc   - row 2
   d    - row 3
or
a - row 0
bb - row 1
ccc - row 2
dddd - row 3

Naturally, you can linearize these data (i.e. to place all rows into an ordinal C array w/o unused gaps):

1st case: aaaabbbccd
2nd case: abbcccdddd

As usually, to access these arrays in an usual C manner array[i][j] we allocate an array of pointers to a basic type then explicitly initialize it in run-time (i-th pointer refers to a start of i-th row in a basic 1D array with triangular array data).

Try to implement: it's so simple task in C...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.