-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
50 lines (45 loc) · 1.24 KB
/
main.c
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
#include <unistd.h>
#include <getopt.h>
#include <stdlib.h>
#include <stdio.h>
#include "maze.h"
int
main(int argc, char *argv[])
{
long long int length = 10, width = 10;
unsigned char *maze;
const char *optstring = "l:w:h";
int option_index = 0;
int opt;
static struct option long_options[] =
{
{ "length", required_argument, NULL, 'l' },
{ "width", required_argument, NULL, 'w' },
{ "help", no_argument, NULL, 'h' },
{ 0, 0, 0, 0 },
};
while( (opt = getopt_long(argc, argv, optstring, long_options, &option_index)) != -1)
{
switch(opt)
{
case 'l':
length = atoi(optarg);
break;
case 'w':
width = atoi(optarg);
break;
case 'h':
printf("--length -l\tspecify the length of maze.\n");
printf("--width -w\tspecify the width of maze.\n");
return 1;
break;
default :
printf("invalid options.\n");
return 0;
break;
}
}
maze = generate(length, width);
draw_in_terminal(maze, length, width);
return 1;
}