I am looking for how to print in C++ so that table column width is fixed.
currently I have done using spaces and |
and -
, but as soon as number goes to double digit all the alignment goes bad.
|---------|------------|-----------|
| NODE | ORDER | PARENT |
|---------|------------|-----------|
| 0 | 0 | |
|---------|------------|-----------|
| 1 | 7 | 7 |
|---------|------------|-----------|
| 2 | 1 | 0 |
|---------|------------|-----------|
| 3 | 5 | 5 |
|---------|------------|-----------|
| 4 | 3 | 6 |
|---------|------------|-----------|
| 5 | 4 | 4 |
|---------|------------|-----------|
| 6 | 2 | 2 |
|---------|------------|-----------|
| 7 | 6 | 4 |
|---------|------------|-----------|