How to use printf output function in C language
This article is about how to use printf output functions in c language. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Description
1. Printf can output various types of data.
2. It is one of the most flexible, complex and commonly used output functions. It controls the output format through format controllers.
The function prototype is in the header file stdio.h. As a special case, however, you do not need to include the stdio.h file before using the printf function.
Grammar
Printf ("format control string", output table column)
Example
# include int main () {int m = 192, n =-234 × double f = 9.8 printf char c ='@'; char * str = "abcdefghi"; / / demonstration width printf ("dlf%4c%8s\ n", n, f, c, str); / demo .demonstration printf ("n:% .9d% .4d\ n", n, n); printf ("f:% .2lf% .4lf% .10lf\ n", f, f, f) Printf ("str:% .5s% .15s\ n", str, str); / / demonstrate the use of flag printf ("masked d, masked% copyright 10d\ n", m, m); / / demonstrate the use of printf ("masked% roomd, nasty% roomd\ n", m, n); / / demonstrate the use of printf ("masked% d, nasty% d\ n", m, n) / / demonstrate the use of spaces printf ("f=%.0lf, f=%#.0lf\ n", f, f); / / demonstrate the use of # return 0;} Thank you for reading! This is the end of the article on "how to use the printf output function in c language". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!