Quote:
#include iostream
#include fstream
using namespace std;
static const int width = 257;
int countlines(ifstream &in);
int main(int numArgs, char *args[]) {
if (numArgs != 2) {
cout << "Usage:\n reader filename.ext";
return 1;
}
ifstream fin(args[1]);
cout << countlines(fin);
fin.close();
return 0;
}
int countlines(ifstream &in) {
int lines = 0;
char null[width];
while (!in.eof()){
in.getline(null, width);
lines++;
}
in.seekg(0, ios::beg);
return lines;
}
|
__________________
Eat antimatter, Posleen-boy!
Last edited by Pragma; 12-11-2003 at 08:12 AM..
|