How to add spaces in a string using C++
Posted: Wed Dec 09, 2009 3:30 am
Pad an empty string ("") with k spaces(10 spaces)
This will print:
Code: Select all
int k = 10;
char *s1 = "ROBOT.LK";
char *s2 = "Laboratories";
printf("%s%*s%s\n",s1,k,"",s2);
Code: Select all
ROBOT.LK Laboratories