-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
43 lines (34 loc) · 826 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <fstream>
int main(const int argc, char* argv[])
{
std::cout << "Output files" << '\n';
if(argc == 1)
{
std::cout << "No files in command line found." << '\n'
<< "Usage: " << argv[0] << " file1 file2 and so on." << '\n' << '\n';
std::cout << "Press Enter to continue . . . ";
std::cin.get();
return 0;
}
int no{ 0 };
while(argv[++no] != nullptr)
{
std::ifstream source(argv[no], std::ios::binary);
std::cout << "File " << argv[no];
if(!source) //Error checking
{
std::cout << " not found." << '\n';
continue;
}
std::cout << ':' << '\n';
char ch;
while (source.get(ch))
std::cout << ch; //Output character by character
source.close();
}
std::cout << '\n';
std::cout << "Press Enter to continue . . . ";
std::cin.get();
return 0;
}