Advertisement
file-stream-object("filename", mode);
File Mode | Description |
---|---|
ios::in | Searches for the file and opens it in read mode only(if the file is found). |
getline (char* arr, int length);
Advertisement
Hello there!
How are you doing?
May you have a blessed day!
//Reading the content of a file using getline() function.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int size = 40;
char arr[size];
//Creating an input stream to read a file
ifstream fin;
//Opening a file named File.txt for reading its content
fin.open("File.txt", ios::in);
while(fin)
{
fin.getline(arr, size);
cout<<arr;
cout<<"\n";
}
fin.close();
return 0;
}
Hello there!
How are you doing?
May you have a blessed day!
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement