Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use printf output function in C language

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report