123

123


#include<iostream>

#include<string>

#include<fstream>

#include<cstring>



using namespace std;


int main()

{

  ofstream fout;

  string filename = "myFile.txt";

  

  char S[249];

  int count = 0;

  const int N = 250;

  

  cout << "Input number of count: ";

  cin >> count;

  

  fout.open(filename);

  

  if(!fout.is_open())

  {

   cout << "File doesn't open!" << endl;

  }

  else

  {

  

   cout << "File is open!" << endl;

  

   for(int i = 0; i < count+1; i++)

   {

   cin.getline(S, N);

   fout << S << endl;

   }

   fout.close();

  }

  

  ifstream fin;

  fin.open(filename);

  

  if(!fin.is_open())

  {

   cout << "File doesn't open!" << endl;

 }

  else

  {

   

  }

  

  fin.close();

system("pause");

return 0;

}

Report Page