Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What is the difference between iostream and iostream.h in C++?
Both <iostream> and <iostream.h> are the header files of C++ language. The .h extension was common in older, non-standard implementations like Turbo C++. The <iostream.h>
The <iostream.h> Header File
The iostream.h header file was part of the early 1990s I/O streams library, developed at AT&T for use with early C++. At that time, C++ was not yet standardized. The purpose of this header file is used to perform the input-output operations.
Example
Following is an example of iostream.h as per Turbo C compiler:
#include<iostream.h>
#include<conio.h>
void main() {
// Clears the screen
clrscr();
int str = "Tutorialspoint";
cout << str << endl;
// wait for key press
getch();
}
The above code produces the following result:
Tutorialspoint
Note: In user input case, you can use cin >> var_name; to take an input from the user.
The <iostream> Header File
The iostream header file is part of the C++ standard library, it was first introduced in 1998 and provides the definition of standard Input/Output related streams and functions.
By using this header, you can use a standard namespace (std) that represents a group of standard library components, classes, functions, and other identifiers.
Example
In this example, we use iostream header file to see its standard usage.
#include<iostream>
using namespace std;
int main() {
string str = "Tutorialspoint";
cout << str << endl;
return 0;
}
The above code produces the following result:
Tutorialspoint
Difference Between <iostream> and <iostream.h>
Here, we provide the tabular differences of both header files based on standardized and non-standardized as follows:
| <iostream.h> | <iostream> |
|---|---|
| .h is the extension of the header file for ANSI standard. | There is no need for an extension for modern C++ standards. |
| There is no use of std namespace. | There is a use of std namespace. |
| It is used in older compilers like Turbo C. | The modern compiler recommended this for C++ development. |
| The implementation of this header file is based on AT&T C++ streams. | This header file was implemented based on the C++ standard in 1998. |
| It may lack an error-handling mechanism. | It uses standard error handling (std::ios::failure). |
| This header file shows inconsistencies with function overloading. | It supports proper function overloading as per C++ standard. |
