What is the use of #include in C++?
#include is a preprocessor command. Before the compiler runs, the preprocessor copies the content of the header file into your file. <iostream> declares std::cout, std::cin, std::cerr and std::endl.
#include <iostream>
int main() {
std::cout << "Hello\n"; // output
std::cerr << "Error stream\n"; // output for errors
}
Output
Hello
Error stream
< > is used for standard headers, and quotes "my.h" for your own files. See C++ Input and Output.
Learn more about the similar topics:
| Tutorials |
|---|
| C++ Introduction |
| C++ History and Versions |
| C++ Features |
| C++ vs C |
| C++ Installation and Setup |
| Your First C++ Program: Hello World |
| C++ Syntax |
| Exercises & Assignments |
|---|
| No Content Found. |