-
Notifications
You must be signed in to change notification settings - Fork 43
/
main.cpp
41 lines (36 loc) · 971 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
#include <iostream>
#include <cstdlib>
#include <cstring>
#include "mc_driver.hpp"
int
main( const int argc, const char **argv )
{
/** check for the right # of arguments **/
if( argc != 2 )
{
/** exit with failure condition **/
return ( EXIT_FAILURE );
}
if( std::strncmp( argv[ 1 ], "-h", 2 ) == 0 )
{
/** simple help menu **/
std::cout << "use -o for pipe to std::cin\n";
std::cout << "just give a filename to count from a file\n";
std::cout << "use -h to get this menu\n";
return( EXIT_SUCCESS );
}
MC::MC_Driver driver;
/** example for piping input from terminal, i.e., using cat **/
if( std::strncmp( argv[ 1 ], "-o", 2 ) == 0 )
{
driver.parse( std::cin );
}
/** example reading input from a file **/
else
{
/** assume file, prod code, use stat to check **/
driver.parse( argv[1] );
}
driver.print( std::cout ) << "\n";
return( EXIT_SUCCESS );
}