-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.cpp
59 lines (50 loc) · 1.12 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Author : Gagan Bihari Mishra
#include "generator.h"
int main(int argc, char **argv){
generator g1;
int width = 0;
//let the people know that it is not handwritten code
cout << "-- This program is generated by " << argv[0] << endl
<< "-- Do manual changes to the code only when you are sure!" << endl
<< "-- if you see any bug, correct the generator code." << endl << endl;
for (int i=1; i<argc;i++)
{
if(argv[i][0] == '-' and argv[i][1])
{
switch (argv[i][1])
{
case 'w':
{
i++;
if(i>=argc){
std::cout << "missing argument for -w = " << std::endl;
return -1;
}
width = atoi(argv[i]);
if (width < 3)
{
cout << "Nothing to do! Exiting now." << endl;
return 0;
}
break;
}
default :
{
cout << "Usage : <program name> -w <width> > <filename>" << endl;
return 1;
}
}
}
}
int err;
err = g1.generate(width);
if (err < 0) cout << "Error generating code! Please debug." << endl;
return 0;
}
string intToString(int i) {
std::stringstream ss;
std::string s;
ss << i;
s = ss.str();
return s;
}