// Dackral Phillips // COMP 6700 - Software Process // 6/18/2K1 // Assignment 2A // This is a program that will count the number of lines in a program. // Basically, any line that has text on it is counted as one physical // line. Blank lines are not . ments are counted, but only if // they are on their own line. // Necessary Included libraries: #include #include #include #include // Begin the main program, and set it up to take in the filename as // an argument. int main(int argc, char* argv[]) { int i; int lines = 0; char buffer[1024]; if (argc == 2) { ifstream program(argv[1], ios::in); while (!(program.eof())) { for (i = 0; i < 1024; i++) { buffer[i] = '\0'; } program.getline(buffer, 1024, '\n'); if (buffer[0] != '\0') { lines++; } } cout << endl << "The total number of lines is: " << lines << endl << endl; } else { cout << endl << "Error: Please type the filename after the program name." << endl; } return 0; }