How much do you know about C++ header files? ——Inventory of common header files of C++

I believe that when you write C/C++ programs, one of the most essential parts is the header file. However, because the header files corresponding to different functions are different, some people (especially me) often encounter the dilemma of forgetting the required header files when writing code. In order to solve this problem, today I specially collected C++ Commonly used header files and the library functions they contain, I hope to help everyone. (Due to space limitations, I just briefly introduce each header file. For more detailed usage, please refer to the link I attached)


1."iostream"  (input&output stream)

#include<iostream>

common use

Input stream " cin>> " and output stream " cout<< ", the following data types can be int, float, double, string, etc., which is quite convenient and recommended.

learn more:

C++ header file iostream detailed explanation icon-default.png?t=M4ADhttps://blog.csdn.net/fengbingchun/article/details/63685373?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165452277616782246474464%2522%25 2C%2522scm%2522%253A%252220140713.130102334. .%2522%257D&request_id=165452277616782246474464&biz_id=0&spm=1018.2226.3001.4187


2."stdio.h"  (standard buffered input&output)

#include<stdio.h>

This is originally a header file in the C language standard function library, but it becomes "cstdio" in C++ (the two are actually similar).

common use

Formatted input "scanf()" and formatted output "printf()" are rich in functions, but compared with "cin" and "cout", it is slightly cumbersome.

It is also a very useful header file.

learn more:

Detailed explanation of C++ header file "cstdio" C%2522scm%2522%253A icon-default.png?t=M4AD% 252220140713.130102334..%2522%257D&request_id=165452376516781483737923&biz_id=0&spm=1018.2226.3001.4187


3."cmath" ( "math.h" )

#include<cmath>

Like "cstdio", the "predecessor" of "cmath" is the header file "math.h" in the C language standard function library, which contains a large number of mathematical formulas for easy calculation.

common use

Find the absolute value "abs()", the sine value "sin()", etc., I won't list them one by one, if you want to know, you can see the link below.

learn more

Detailed explanation of C++ header file "cmath" 522%252C%2522scm%2522%253A icon-default.png?t=M4AD% 252220140713.130102334.pc%255Fall.%2522%257D&request_id=165452386816780366566485&biz_id=0&spm=1018.2226.3001.4187


4."windows.h"

#include<windows.h>

This is a magical header file that can be explored by yourself. (To put it bluntly, I also know less)

common use 

"GetAsyncKeyState()()" determines whether a key is pressed.

"system("cls")" clears the screen.

"Sleep()" delay in milliseconds.

learn more

Detailed explanation of the C++ header file "windows.h" 252C%2522scm%2522 icon-default.png?t=M4AD% 253A%252220140713.130102334..%2522%257D&request_id=165452422016781683962560&biz_id=0&spm=1018.2226.3001.4187


5."algorithm"

#include<algorithm>

This is the standard algorithm library for C++

common use

Find the maximum value "max()", find the minimum value "min()", sort function "sort()", etc.

learn more

Detailed explanation of the C++ header file "algorithm" %252C%2522scm%2522%253A icon-default.png?t=M4AD% 252220140713.130102334..%2522%257D&request_id=165452482416781685358518&biz_id=0&spm=1018.2226.3001.4187


6."string" "string.h" "cstring"

These three are header files related to the use of strings

The main purpose

The array initialization function "memset()" inserts the string "insert()", removes the string "erase()", etc.

learn more

Detailed explanation of the C++ header file "string.h" 2522%252C%2522scm%2522 icon-default.png?t=M4AD% 253A%252220140713.130102334..%2522%257D&request_id=165452375716781483741229&biz_id=0&spm=1018.2226.3001.4187


6."bits/stdc++.h"

#include<bits/stdc++.h>

It is called the "universal header file" of C++, which shows how powerful it is, but I didn't put it in front because its shortcomings are also very obvious-it will greatly slow down the speed of the program. This header file almost contains There are about dozens of library functions in C++, but many of them are not used by us. Therefore, it is recommended to use whatever header files are needed . did not say)

The main purpose

I don't need to say more.

learn more

Detailed explanation of C++ header file "bits/stdc++.h" 522%252C%2522scm icon-default.png?t=M4AD% 2522%253A%252220140713.130102334..%2522%257D&request_id=165452140316781818727446&biz_id=0&spm=1018.2226.3001.4187


Well, that’s all for this sharing, thank you for watching!

I have read this far, can you kindly give me a three-link ヾ(≧▽≦*)o

(Such a good article, don’t rush to collect it)

Guess you like

Origin blog.csdn.net/weixin_68703606/article/details/125154692