how do I align my figures so the column appers to be right justified
i have several lines.
Printable View
how do I align my figures so the column appers to be right justified
i have several lines.
Try
printf( "%5d", 123 );
printf( "%5d", 12345 );
Or
int iWidth=COLUMN_WIDTH;
sprintf(sBuffer,"%*d",iWidth,iValue);
the * is taken as the width of the cell. Works with printf() ect.
Don't you just hate people that post the same thing over and over again and don't bother reading the reply to it?
Quzah.
It is important to specify the size of the fields.
fprintf(fptr,"%2d%20s%8.2lf",num," ", float_num);
I have recently discovered the utility of specifying the field sizes because I recently used datafiles like this. Cprogramming borad screwed this up, the name fields should be the same length but this boards formatting ****ed it.
4902348093esome name94023942304809348204
40982304984another 42392904832094832049
40394803240yet more 40934223048320940393
This file can be used by more than one program. In order to skip pieces of data that you do not want to read use the star.
fprintf(fptr,"%*2c,%3d", num);
In this code the star allows the first two characters to be skipped.