[ create a new paste ] login | about

Link: http://codepad.org/Uj59Mkbk    [ raw code | output | fork ]

C++, pasted on Sep 25:
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const char INPUTFILE[] = "input.dat";
const char OUTPUTFILE[] = "output.dat";
int main() {
  vector<char> v;
  ifstream fin(INPUTFILE);
  if (!fin) {
    cerr << "cannot open the file: " << INPUTFILE << " for input." << endl;
    return -1;
  }
  ofstream fout(OUTPUTFILE);
  if (!fout) {
    cerr << "cannot open the file: " << OUTPUTFILE << " for output." << endl;
    return -1;
  }
  fin.unsetf(ios::skipws);
  fout.unsetf(ios::skipws);
  while (fin.eof() != true) {
    char c;
    fin >> c;
    v.push_back(c);
  }
  cout << "size: " << v.size();
  for (vector<char>::iterator p = v.begin(); p != v.end(); p++)
    fout << *p;
  fout.close();
  fin.close();
  return 0;
}
/* end */


Output:
1
2
3
cannot open the file: input.dat for input.

Exited: ExitFailure 255


Create a new paste based on this one


Comments: