当前位置:网站首页>C language | printf output function
C language | printf output function
2022-06-24 17:25:00 【Kobayashi C language】
C The concept of language output
The output is based on the computer host , The output of data from a computer to an output device is called output ,C The language itself does not contain output statements , If you don't add headers , The following code will report an error .
//#include<stdio.h>// The header file
int main()// The main function Program entry
{
printf("Hello xiaolin!\n");// \n It means new line
return 0;
}Compilation result :
D:\ Yan Xiaolin \ Handout materials \1-100\ test .cpp In function 'int main()': D:\ Yan Xiaolin \ Handout materials \1-100\ test .cpp [Error] 'printf' was not declared in this scope
C Language printf usage
1、 General format
printf( Format control , Output table columns )
- Format control
Format control is a string enclosed in double quotation marks , call “ Conversion control string ”, abbreviation “ Format string ”, contain :
- Format statement : from % And format characters , Such as %d、%f.
- Ordinary character : That is, the characters that need to be output as they are .
- Output table columns
- The output table column is some data that the program needs to output , It can be a constant 、 Variable or expression .
C Language format characters
1、d Format symbol
Used to output a signed decimal integer .
2、c Format symbol
Used to output a character
3、s Format symbol
Used to output a string
4、f Format symbol
Used to output real numbers , Output in decimal form , There are two uses :
① Basic type , use %f, Do not specify the length of the output data , According to the actual situation of the data, the system determines the number of columns occupied by the data .
② Specify the data width and scale , use %m.nf,m The data representing the output occupies m That's ok ,n It means that it contains n Decimal place .
③ The output data is aligned to the left , use %-m.nf, Function and ② almost , That's the data to the left , Fill in the space at the right end .
5、e Format symbol
Used to specify that real numbers are output exponentially .
C Language format characters | significance |
|---|---|
d | Output a decimal integer by symbol |
c | Output a character |
s | Output a string |
f | Output real numbers in decimal form |
%m.nf | m Specify the data width ,n Specify the number of decimal places |
e | Output real numbers in exponential form |
l | And d The format is the same , Used to d Format symbol |
o | Output as octal integer |
x | Output as a hexadecimal number |
u | Output unsigned decimal integer data |
g | Output floating point number , The system selects automatically f or e Format symbol |
above , If you read it and think it helps you , Just give Xiao Lin a compliment , Share it with the people around you , In this way, Kobayashi has the power to renew itself , Thank you on your knees ~
C Language learning route C Language development tools
VC6.0、Devc++、VS2019 Use the tutorial
100 Please go to the official account for the source code cases :C From language introduction to mastery
边栏推荐
- How to learn go language happily? Let's go!
- 04. Tencent cloud IOT device side learning - network connection and device authentication
- Using easyjson to improve the efficiency of serialization transmission
- About with admin option and with grant option
- Zblog determines whether a plug-in installs the enabled built-in function code
- Leveldb source code analysis -- writing data
- 5g brings opportunities and challenges. Are you ready to defend against DDoS?
- Use BPF to count network traffic
- zblog系统如何根据用户ID获取用户相关信息的教程
- Explanation of MySQL indexing principle
猜你喜欢
随机推荐
Yupi made an AI programming nickname generator!
Sigai intelligent container damage identification products are deployed in Rizhao Port and Yingkou Port
[go language development] start to develop Meitu station from 0 - Lesson 5 [receive pictures and upload]
Tencent released "warehouse express" and issued "ID card" for each commodity!
[DB Bao 45] MySQL highly available mgr+consult architecture deployment
liver failure! My friend made a programming navigation website!
Solution to the problem that kibana's map cannot render longitude and latitude coordinate data
Classic examples of C language 100
TRCT test cloud + article online speed
Ramda's little-known side
Erc-20 Standard Specification
Realize business development on behalf of small programs, and 99% restore the function of service category management in the background of official account
让UPS“印象派用户”重新认识可靠性
问题有多大,中台就有多大
Solutions for RTSP video streaming played by several browsers
Go kit microservice integrates Promtheus to solve monitoring alarm problems
CentOS 7 installing SQL server2017 (Linux)
Explore cloudera manager management software tuning (1)
Can you remember the code of a programming boss? Can you hit it out without Baidu?
How to compile and debug go runtime source code

