Can anyone help me in printing the string
aligned to center in C?
For example:
int main()
{
int a = 20;
char x[10] = "Hello";
char y[10] = "Hello";
printf ("%*s\n",a, x );
printf ("%-*s\n",a,y);
}
In the above the first prints Hello
aligned to the right and the second printf
to the left like this
Hello
Hello
restricting the length for each to 20.
Is there a way to print Hello aligned to the center.
Hello
restricting the total length to 20.
Thankyou in advance