/* standard includes section */ #include <iostream> #include <fstream> #include <iomanip> #include <vector> #include <algorithm> #include <string> #include <math.h> #include <assert.h> using namespace std; /* change to reflect root name of the problem */ #define PROBLEM "count" string infile; ifstream in; string outfile; ofstream out; void solve_problem(); int main(int argc, char *argv[]) { infile = PROBLEM; infile += ".in"; in.open(infile.c_str()); if (!in) cout << "could not open input file " << infile << endl; outfile = PROBLEM; outfile += ".out"; out.open(outfile.c_str()); if (!out) cout << "could not open output file " << outfile << endl; if (!in || !out) exit(1); solve_problem(); in.close(); out.close(); return 0; } /* this is the real work: the input and output files are opened, and you must solve the problem. This version merely reads in lines from the input file, prints them back out on the output file, followed by the total number of lines processed. */ void solve_problem() { int count=0; string line; while (getline(in,line)) { ++count; } out << count << endl; }