text: Q:
  
  Text justification C language
  
  I have to solve a problem that involves left justification string length and leading zeros.
  I have the following table :
  
  BEGIN
  CLOSE
  CONCATENATE
  DELETE
  END
  INITIALIZE
  PRINT
  WRITE
  
  This is produced by a simple program.
  My problem is to find out how to convert it like that :
  
  It has to be perfectly aligned.
  I have to use left justification and not the "tab" ( \t ).
  Also, i have to calculate the string length. My code so far is the following :
   int i;
  
   int long temp;
  
   char a = 'a';
  
   char command[][12]= {
  
  "BEGIN", "CLOSE", "CONCATENATE", "DELETE",
  "END" , "INITIALIZE", "PRINT", "WRITE"
  
  };
  
  int main()
  
  {
  
  printf("a/a \tCommand \tLength\n");
  
  for (i=0 ; i<8 ;i++){
  
      temp = strlen(command[i]);
  
      printf("%c. %10s %ld \n",a, command[i], temp);
  
      a++;
  
  }
  
  printf("\n");
  
  return 0;
  
  }
  
  I am trying to add an integer instead of the number ( 10 ) in the printf but i don't know if it is the right solution.
  For example something like this:
      printf("%c. %10s %%dld \n",a, command[i], integer,  temp);
  
  Any help is appreciated.
  Thank you.
  
  A:
  
  as an example of how to output what you want:
  the line: 
  printf("%c. %10s %ld \n",a, command[i], temp);
  
  should be written as:
  printf("%c. %-10.10s %5.ld \n",a, command[i], temp);
  
  and this line:
  printf("%c. %10s %ld \n",a, command[i], temp);
  
  should be written as:
  printf("%c. %-10.10s %5.ld \n",a, command[i], temp);
  
  Notice the '-' on the %s for left justification, 
  Notice the 10.10 on the %s to force the field to always to 10 characters
  Notice the '5.' on the %d to force the field to always be 5 characters
  (right justified)
  There are other modifications for fill characters other than space, to inhibit leading 0 suppression, etc.
  you may want to look here for further details:
  http://www.tutorialspoint.com/c_standard_library/c_function_printf.htm
  
  