I'm having trouble aligning a table
Code:/* unaligned table */ City | x coord | y coord ---------------------+---------+--------- Nowhere 28.80 17.60 Somewhere 5.60 79.12 Whoknows 55.30 49.90 Elsewhere 22.22 11.11 /* aligned table */ City | x coord | y coord ---------------------+---------+--------- Elsewhere 22.22 11.11 Nowhere 28.80 17.60 Whoknows 55.30 49.90 Somewhere 5.60 79.12
The tricky part is, the file is dynamic so if i change the contents the alignment is broken:
Code:/* unaligned table */ City | x coord | y coord ---------------------+---------+--------- city1 4.40 7.70 city2 3.30 8.80 /* aligned table */ City | x coord | y coord ---------------------+---------+--------- city1 4.40 7.70 city2 3.30 8.80
Here's what my code looks like for the unaligned version:
Code:printf("City | x coord | y coord"); printf("\n---------------+---------+---------\n"); printf("%9s %15.2f %9.2f\n", startptr->cityname,startptr->xcp, start-ptr>yco);