Sunday, 13 March 2016

Write A C++ Program To Read A Line By Line And Write Line By Line Using File

#include <iostream>
#include <fstream>
using namespace std;
//Ghanendra Yadav
int main(int argc, char *argv[])
{
  ifstream in("example.txt");

/*Here You Have To Create A File And Write Into File What You Want Then Save With Any Extension With File Name As Above Shown */

  if(!in) {
    cout << "Cannot open input file. Or File Is Not Located \n";
    return 1;
  }

  char str[255];

  while(in) {
    in.getline(str, 255);
    if(in) cout << str << endl;
  }

  in.close();

  return 0;
}


Input:-



Output"-


No comments:
Write comments

Recommended Posts × +