1: //display_files.cpp
2: //Displays contents of each file listed on the command line.
4: #include <iostream>
5: #include <string>
6: #include <cstdlib>
7: using namespace std;
9: int main(int argc, char* argv[])
10: {
11: if (argc == 1)
12: {
13: cout << "\nThis program displays the contents of each file "
14: "listed on the command line,\nin the order listed. "
15: "Each of those files must (of course) be a textfile."
16: "\n\nTypical usage:"
17: "\ndisplay_files first_file second_file third_file\n";
18: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
19: return 1;
20: }
21: else
22: {
23: for (int i=1; i<argc; i++)
24: {
25: string command = "type ";
26: command += argv[i];
27: command += " | more";
28: system(command.c_str());
29: system("pause");
30: }
31: }
32: }