Questions:
C Plus Plus Program to Illustrate Reading of Data from a File
Explanation:
This C Program illustrates reading of data from a file. The program opens a file which is present. Once the file opens successfully, it uses ifstream library call to read the content.
ifstream: This data type represents the input file stream and is used to read information from files.
Code:
Output:
Related Articles :
C Plus Plus Program to Create a File & Store Information
C Plus Plus Program to Illustrate Reading of Data from a File
Explanation:
This C Program illustrates reading of data from a file. The program opens a file which is present. Once the file opens successfully, it uses ifstream library call to read the content.
ifstream: This data type represents the input file stream and is used to read information from files.
Code:
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void main() {
       ifstream file("Temp.txt");//creating txt file
       while (file) {
              string temp;
              getline(file,
temp);
              cout
<< temp << endl;
       }
       file.close();
}
Output:
Related Articles :
C Plus Plus Program to Create a File & Store Information


0 Questions:
Post a Comment