What is meant by stream? Write a program that reads content of file data.txt and displays the content in monitor.

This answer is restricted. Please login to view the answer of this question.

Login Now

Stream in C++ means a stream of characters that gets transferred between the program thread and input or output. There are a number of C++ stream classes eligible and defined which is related to the files and streams for providing input-output operations. 

All the classes and structures maintaining the file and folders with hierarchies are defined within the file with iostream standard library. Classes associated with the C++ stream include ios class, istream class, and ostream class.

Program to read data from file:

#include <iostream>
#include <fstream>
using namespace std;

int main() {
	fstream file;
	file.open("data.txt", ios::in);

	if (!file) {
		cout << "File Doesn't Exists!!!" << endl;
	}else {
		char ch;
		while (1) {
			file >> ch;
			if (file.eof())
			cout << ch;

	return 0;
If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

  Loading . . .