Explain how can I right-justify a string?



Explain how can I right-justify a string?..

Answer / Bhagya Laxmi Upadhyay

In C, you can use the `printf()` function's format specifier `%*s` to specify the total width of the string and right-justify it. For example, `printf("%.12s", "Hello World");` will print Hello World with a minimum width of 12 characters and right justification.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

what do u mean by Direct access files? then can u explain about Direct Access Files?

1 Answers   LG Soft,


How do you generate random numbers in C?

1 Answers  


pascal triangle program

2 Answers  


Difference between C and Embedded C?

1 Answers  


write a program to compare 2 numbers without using logical operators?

5 Answers   IBM,


I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....

2 Answers  


What is the use of function in c?

1 Answers  


Why is void main used?

1 Answers  


Tell us something about keyword 'auto'.

1 Answers  


Can I initialize unions?

1 Answers  


What is the use of gets and puts?

1 Answers  


4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it. i have done maximum par but i m findind problem in the commented area. please help...

3 Answers  


Categories