EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

C++ Header Files

Home » Software Development » Software Development Tutorials » C ++ Programming Tutorial » C++ Header Files

C++ Header Files

Introduction to C++ Header Files

Header files are used in this  programs which contains definition or implementation of the predefine functions and variables. The header files can be used in this programs by using the preprocessor directives that is #include. All header files of this may or may not end by .h extension, where as in C all header files must end by .h extension.

Syntax

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

The syntax to include header files:

#include<iostream>

Or

#include"iostream"

Types of Header Files in C++

Types of header files

  1. System header files – These are predefined header files presents in this compilers.
  2. User header files – these are user defined header file includes in this programs by #define directive.

Next we see the list of system defined header files category wise below –

  • Input/output library

Code:

<iostream> - This defines standard stream objects.
<ios> - This defines several typedefs and class template of std::ios_base class, std::basic_ios.
<istream> - This defines several typedefs and class template of std::basic_istream.
<ostream> - This defines several typedefs and class template of std::basic_ostream, std::basic_iostream.
<fstream> - This defines several typedefs and class template of std::basic_ifstream, std::basic_fstream, std::basic_ofstream.
<sstream> - This defines several typedefs and class template of std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream.
<iosfwd> - This defines library for input/output forward declarations classes.
<syncstream> - This defines several typedefs and class template of std::basic_osyncstream, std::basic_syncbuf.
<strstream> - This defines std::istrstream, std::strstream, std::ostrstream.
<iomanip> - This defines formatting function of input and output.
<streambuf> - This defines class template of std::basic_streambuf.
<cstdio> - This defines C input/output functions Concepts.
<concepts> - This defines library for fundamental concepts Coroutines.
<coroutine> - This defines library for coroutine support.

  • Strings library

Code:

<cctype> - This defines library for Functions to determine character type.
<cwctype> - This defines library for Functions to determine wide character type.
<string> - This defines library for class template of std::basic_string.
<cstring> - This defines library for string handling functions of narrow character.
<cuchar> - This defines library for C Unicode character conversion functions.
<string_view> - This defines library for class template of std::basic_string_view.
<format> - This defines library for std::format.
<charconv> - This defines library for class template of std::from_chars and std::to_chars

  • Containers library

Code:

<array> - This defines library for container of std::array.
<list> - This defines library for container of std::list.
<vector> - This defines library for container of std::vector.
<set> - This defines library for association container of std::set and std::multiset.
<unordered_set> This defines library for association container of std::unordered_set and std::unordered_multiset.
<deque> - This defines library for container of std::deque.
<forward_list> - This defines library for container of std::forward_list.
<map> - This defines library for association container of std::map and std::multimap.
<unordered_map> - This defines library for unordered association container of std::unordered_map and std::unordered_multimap.
<stack> - This defines library for container adaptor of std::stack.
<span> - This defines library for view of  std::span.
<queue> - This defines library for container adaptor of std::queue and std::priority_queue.

  • Numerics library

Code:

<numbers> - This defines library for Math constants.
<cmath> - This defines library for mathematics functions.
<numeric> - This defines library for Numeric operations.
<complex> - This defines library for Complex number.
<valarray> - This defines library for arrays representing and manipulating of values class.
<random> - This defines library for generators and distributions of random number.
<ratio> - This defines library for Compile time rational arithmetic
<cfenv> - This defines library for functions to access Floating-point environment.
<bit> - This defines library for function for Bit manipulation.

Popular Course in this category
C++ Training (4 Courses, 5 Projects, 4 Quizzes)4 Online Courses | 5 Hands-on Projects | 37+ Hours | Verifiable Certificate of Completion | Lifetime Access | 4 Quizzes with Solutions
4.5 (4,828 ratings)
Course Price

View Course

Related Courses
Java Training (40 Courses, 29 Projects, 4 Quizzes)C Programming Training (3 Courses, 5 Project)
  • Error handling

Code:

<exception> - This defines library for utilities of Exception handling.
<system_error> - This defines library for platform-dependent error code, std::error_code.
<cerrno> - This defines library for error number.
<stdexcept> - This defines library for exception objects.
<cassert> - This defines library for macro(Conditionally compiled) that compares its argument to zero.

  • Utilities library

Code:

<utility> - This defines library for utility.
<csignal> - This defines library for signal management.
<cstdlib> - This defines library for general purpose utilities like dynamic memory allocation, program control, sort, random numbers and search.
<csetjmp> - This defines library for an execution context like Macro or function that saves or jumps location.
<typeinfo> - This defines library for runtime type information utilities.
<cstdarg> - This defines library for handling argument lists of variable length.
<typeindex> - This defines library for std::type_index.
<bitset> - This defines library for class template std::bitset.
<type_traits> - This defines library for Compile time type information.
<functional> - This defines library for Function invocations, function objects, Reference wrappers and Bind operations.
<ctime> - This defines library for C time/date utilities.
<chrono> - This defines library for C++ time utilities.
<initializer_list> - This defines library for class template of std::initializer_list.
<cstddef> - This defines library for standard typedefs and macros.
<tuple> - This defines library for class template of std::tuple.
<optional> - This defines library for class template of std::optional.
<any> - This defines library for class template of std::any.
<variant> - This defines library for class template of std::variant.
<source_location> - This defines library for to obtain location of source code.
<compare>- This defines library for comparison operator.
<version> - This defines library for information implementation-dependent library.

  • Numeric limits

Code:

<limits> - This defines library for to query properties of arithmetic types.
<climits> - This defines library for limits of integral.
<cstdint> - This defines library for fixed-size and limits of other data types.
<cfloat> - This defines library for limits of float.
<cinttypes> - This defines library for conversions, formatting macros , intmax_t and uintmax_t math.

  • Dynamic memory management

Code:

<memory> - This defines library for utilities of higher level memory management.
<new> - This defines library for utilities of Low-level memory management.
<memory_resource> - This defines library for resource of Polymorphic allocators and memory.
<scoped_allocator> - This defines library for class of Nested allocator.

  • Iterators library

Code:

<iterator> - This defines library for iterators range.

  • Ranges library

Code:

<ranges> - This defines library for utilities and adaptors of Range access, primitives, requirements.

  • Algorithms library

Code:

<execution> - This defines library for algorithm execution policies for parallel versions.
<algorithm> - This defines library for Algorithms used on ranges.

  • Localization library

Code:

<clocale> - This defines library for utilization of C localization.
<locale> - This defines library for utilities Localization.
<codecvt> - This defines library for facilities of Unicode conversion.

  • Filesystem library

Code:

<filesystem> - This define classes and functions for std::path.

  • Regular Expressions library

Code:

<regex> - This defines library for regular expression classes, algorithms and iterators.

  • Atomic Operations library

Code:

<atomic> - This defines library for Atomic operations.

  • Thread support library

Code:

<stop_token> - This define stop tokens of std::jthread.
<thread> - This defines library for classes and function of std::thread.
<mutex> - This define primitives for mutual exclusion.
<shared_mutex> - This define primitives for shared mutual exclusion.
<semaphore> - This define semaphores.
<future> - This define asynchronous computations primitives.
<latch> - This define latches.
<condition_variable> - This define conditions for thread waiting.
<barrier> - This define barriers.

 How and to Why use C++ Header Files?

Next we write the example to see how and to why use header files below –

Code:

#include"iostream"
#include<string>
using namespace std;
int main()
{
string name;
cout <<"Please enter your name : ";
getline(cin,name);
cout<<"Your name is = "<<name;
return 0;
}

Output:

C++ Header Files1

Conclusion

Header files definition for predefine functions and variables. To use a predefine function the specific header file needs to be include.

Recommended Articles

This is a guide to C++ Header Files. Here we discuss Introduction to Header Files, Types with codes, How and to why use with code and output. You can also go through our other related articles to learn more –

  1. C++ Standard Template Library
  2. String in C
  3. C++ begin()
  4. C++ test()

All in One Software Development Bundle (600+ Courses, 50+ projects)

600+ Online Courses

50+ projects

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
C plus plus Programming Tutorial
  • Basic
    • Introduction To C++
    • What is C++
    • Features of C++
    • Applications of C++
    • Best C++ Compiler
    • C++ Data Types
    • C++ Double
    • C++ unsigned int
    • User Defined Data Types in C++
    • Variables in C++
    • C++ Keywords
    • Pointers in C++
    • C++ Void Pointer
    • Function Pointer in C++
    • Iterator in C++
    • C++ Commands
    • Object in C++
    • C++ Literals
    • C++ Reference
    • C++ Undefined Reference
    • String in C++
    • C++ Programming Language (Basics)
    • C++ Identifiers
    • C++ Header Files
    • Type Casting in C++
    • C++ Formatter
  • Operators
    • C++ Operators
    • Arithmetic Operators in C++
    • Assignment Operators in C++
    • Bitwise Operators in C++
    • Relational Operators in C++
    • Boolean Operators in C++
    • Unary Operators in C++
    • C++ Operator[]
    • Operator Precedence in C++
    • C++ operator=()
  • Control Statements
    • Control Statement in C++
    • if else Statement in C++
    • Else If in C++
    • Nested if in C++
    • Continue Statement in C++
    • Break Statement in C++
    • Switch Statement in C++
    • goto Statement in C++
    • C++ Struct
    • Loops in C++
    • Do While Loop in C++
    • Nested Loop in C++
  • Functions
    • C++ String Functions
    • Math Functions in C++
    • Friend Function in C++
    • Recursive Function in C++
    • Virtual Functions in C++
    • strcat() in C++
    • swap() in C++
    • strcmp() in C++
    • ceil function in C++
    • C++ begin()
    • size() in C++
    • C++ test()
    • C++ any()
    • C++ Bitset
    • C++ find()
    • C++?Aggregation
    • C++?String append
    • C++ String Copy
    • C++ end()
    • C++ endl
    • C++ push_back
    • C++ shuffle()
    • malloc() in C++
    • C++ reserve()
    • C++ unique()
    • C++ sort()
    • C++ find_if()
    • Reflection in C++
    • C++ replace()
    • C++ search()
    • C++ Memset
    • C++ size_t
    • C++ Substring
    • C++ Max
    • C++ absolute value
    • C++ memcpy
    • C++ wchar_t
    • C++ free()
    • C++ sizeof()
    • C++ Move Semantics
  • Array
    • Arrays in C++
    • 2D Arrays in C++
    • 3D Arrays in C++
    • Multi-Dimensional Arrays in C++
    • C++ Array Functions
    • String Array in C++
    • C++ Length of Array
    • C++ arraylist
  • Constuctor and Destructor
    • Constructor and Destructor in C++
    • Constructor in C++
    • Destructor in C++
    • Copy Constructor in C++
    • Parameterized Constructor in C++
  • Overloading and overriding
    • Overloading and Overriding in C++
    • Overloading in C++
    • Overriding in C++
    • Function Overloading in C++
    • Function Overriding in C++
    • Method Overloading in C++
  • Inhertiance
    • Types of Inheritance in C++
    • Single Inheritance in C++
    • Multiple Inheritance in C++
    • Hierarchical Inheritance in C++
    • Multilevel Inheritance in C++
    • Hybrid Inheritance in C++
  • Sorting
    • Sorting in C++ 
    • Heap Sort in C++
    • C++ Vector Sort
    • Insertion Sort in C++
    • Selection Sort in C++
  • Advanced
    • C++ namespace
    • Encapsulation in C++
    • Access Modifiers in C++
    • Abstract Class in C++
    • C++ Class and Object
    • What is Template Class in C++?
    • C++ Algorithm
    • Data Structures and Algorithms C++
    • C++ Garbage Collection
    • Virtual Keyword in C++
    • Access Specifiers in C++
    • Storage Class in C++
    • Call by Value in C++
    • Multimap in C++
    • C++ Multiset
    • C++ Lambda Expressions
    • Stack in C++
    • C++ Static
    • C++ static_cast
    • Deque in C++
    • C++ Vector Functions
    • C++ 2D Vector
    • C++ List
    • C++ Mutable
    • Enum in C++
    • Abstraction in C++
    • Signal in C++
    • C++ Queue
    • Priority Queue in C++
    • Regular Expressions in C++
    • C++ Hash Table
    • File Handling in C++
    • C++ Stream
    • ifstream in C++
    • C++ ofstream
    • C++ fstream
    • C++ Read File
    • C++ iomanip
    • Macros in C++
    • Templates in C++
    • C++ setprecision
    • C++ Int to String
    • C++ thread( )
    • C++ Thread Pool
    • C++ thread_local
  • Programs
    • Patterns in C++
    • Star Patterns In c++
    • Swapping in C++
    • Reverse Number in C++
    • Palindrome Program in C++
    • Palindrome in C++
    • Factorial Program in C++
    • Fibonacci Series in C++
    • Square Root in C++
    • Random Number Generator in C++
    • Prime Number in C++
    • Leap Year Program in C++
    • Anagram in C++
    • Armstrong Number in C++
    • Reverse String in C++
    • Socket Programming in C++
    • Matrix Multiplication in C++
    • C++ using vs typedef
    • C++ vector vs list
    • C++ vector vs array
  • Interview question
    • C++ Interview Questions
    • Multithreading Interview Questions C++

Related Courses

C++ Training Course

Java Training Course

C Programming Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - C++ Training Course Learn More