fork download
  1. #include <stdio.h>
  2.  
  3. #define WIDTH 10 //for 32bit int positive
  4.  
  5. int main(void){
  6. int value = 50;
  7. printf("%.*s%i\n", WIDTH - snprintf(NULL, 0, "%i", value), "__________", value);
  8. //use by GCC extension
  9. //printf("%.*s%i\n", WIDTH - snprintf(NULL, 0,"%i",value), (char[WIDTH+1]){ [0 ... (WIDTH-1)] = '_'}, value);
  10. }
  11.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
________50