How to use the printf output function of C language
This article mainly introduces "how to use the printf output function of c language". In the daily operation, I believe that many people have doubts about how to use the printf output function of c language. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to use the printf output function of c language". Next, please follow the editor to study!
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;} at this point, the study on "how to use the printf output function of c language" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!