In: Computer Science
How do I add white space in the beginning of my printf statement in C? I also need the white space to be dynamic by using an int value as reference for the amount of spaces. Thanks!
Code with example
#include<stdio.h>
int main()
{
int indent;
char *string ="My name is jay";
printf("How many space you neede: ");
scanf("%d",&indent);
printf("%*s%s ", indent, "", string);
return 0;
}
output
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.