My question is that "format specifiers" in c language but how can I control its "width" please tell me that how it is working. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

My question is that "format specifiers" in c language but how can I control its "width" please tell me that how it is working.

#include <stdio.h> int main() { printf("Color: %s, Number: %d, float: %5.2f \n", "red", 42, 3.14159); /* Color: red, Number: 42, float: 3.14 */ printf("Pi = %3.2f \n", 3.14159); /* Pi = 3.14 */ printf("Pi = %8.5f \n", 3.14159); /* Pi = 3.14159 */ printf("Pi = %-8.5f \n", 3.14159); /* Pi = 3.14159 */ printf("There are %d %s in the tree. \n", 22, "apples"); /* There are 22 apples in the tree. */ }

9th May 2020, 8:34 AM
smart gamer
1 Answer
0
Please just give me the main idea
13th May 2020, 7:18 AM
smart gamer