/////////////////////////////////////////////////////////////// // // // top.cpp - send first few file lines to output // // // // version: 2.0 // // Language: Borland C++, ver 5.0 // // Platform: Dell Pentium 200, Windows NT 4.0 // // Application: CSE687 Example // // Author: Jim Fawcett // // CST 2-187, (315) 443-3948 // // fawcett@neptune.syr.edu // /////////////////////////////////////////////////////////////// /* usage: top [-15] file1.hpp file2.cpp .. */ /////////////////////////////////////////////////////////////// // Build Process // // ------------- // // Files required: // // top.cpp, \bc5\lib\32bit\wildargs.obj // // // // build command for Neptune cluster: // // bcc32 -w+ top.cpp wildargs.obj // // // /////////////////////////////////////////////////////////////// /* Maintenance History ------------------- ver 2.0 : 10 Jan 98 - move static global variable dispLines to become local variable in main - use standard C++ string class in place of custom str class ver 1.1 : 09 Jan 98 - cosmetic modifications to this page ver 1.0 : 24 Dec 95 - first release */ // #include // ifstream(), >>, <<, cout #include // atoi() #include using namespace std; //----< display top few lines of file >------------------------ void showTop(char *fileName, int dispLines) { // open file ifstream in(fileName); if(!in.good()) { cerr << "can't open file " << fileName << endl; return; } // announce file name to output cout << fileName << endl; // read dispLines strings from the top of input file // and send to standard output string s; int j; for(j=0; j------------------- void main(int argc, char *argv[]) { int dispLines = 10; int i; for(i=1; i