Right justifying and left justifying values : printf Justify « printf scanf « C Tutorial






#include <stdio.h>

int main()
{ 
   printf( "%10s%10d%10c%10f\n\n", "hello", 7, 'a', 1.23 );
   printf( "%-10s%-10d%-10c%-10f\n", "hello", 7, 'a', 1.23 );

   return 0;

}
hello         7         a  1.230000

hello     7         a         1.230000








4.16.printf Justify
4.16.1.Flags
4.16.2.Right justifying and left justifying values