c printf right pad with space

C
/*Pads the to the right of the string with at most `num` spaces,
dending on the length of `str`*/
printf("%-*s", num, str);
Source

Also in C: