Sunday, 13 March 2016

C++ Program To Read And Display File Line By Line Using File Handling

Problem:- C++ program to read and display text file line by line or c++ program to display the contents of a text file or c++ display text file on screen or c++ program to create a file and display its contents or write a c++ program to display the contents of a file in reverse order or c++ read text file line by line or c++ print contents of file or write a c++ program which copies one file to another
c program to display the contents of a file on the screen or c++ read text file line by line.

Explanation:- First we have to create a file with extension (like .txt) after that by using the program we have to print the file in console screen. Always remember we have to read the file by line by line and also write the file line by line in console screen and one more thing file should be in the same folder in which our program already exists. We can give the file name in console screen so no need to give the filename in a program.


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

int main(int argc, char *argv[])
  ifstream in;
  char filename[20];

cout<<"Enter The File Name With Extension\n";

/*Here You Have To Create A File And put some data on it. 
Then Save the with Any Extension With File Name As Above Shown */

    cout << "Cannot Open File. Or File Not Find\n";
    return 1;

  char str[1000];

cout<<"\nFile is Given Below\n\n";
    in.getline(str, 1000);
cout << str << endl;


  return 0;



C++ Program To Read And Display Text File Line By Line Using File Handling


C++ Program To Read And Display Text File Line By Line Using File Handling

You May Like This

1. C Program For Open A File (Or Open The Same Program Itself ) Itself Using File Handling

2. C++ Program To Merge Two File Into Third File Using File Handling

3. C++ Program For Copy One File To Another Using File Handling

4. C++ Program To Display The List Of Current Directory/Folder Using File

5. C++ Program For Count A Character In File Using File

6. C++ Program For Reading A Number From File And Sum Of No. Line By Line Using File

7. C++ Program For Store Employee Information And Display Using Structure

8. C Program For Find A Grade Of Given Marks Using Switch Case

9. C Program For HEAP Sort In Ascending Order Also Show Complexity

10. C++ Program For Selection Sort Using Function

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:-

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment