-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
executable file
·45 lines (38 loc) · 944 Bytes
/
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
/* This file contains the main function for the program */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "helper.h"
#include "io.h"
#include "plotter.h"
int main(int argc, char **argv)
{
int errorCode = 0; /* Used to check if an error occurred */
LinkedList *list = NULL;
if (argc != 2)
{
printf("Usage: %s <inputfilename>\n", argv[0]);
}
else
{
/* The linked list is defined and initialized here
* because it is passed between two functions
*/
list = (LinkedList *) malloc (sizeof(LinkedList));
list->head = NULL;
/* parseLine goes through each line in the filename passed into
* it through argv[1], error checking and then putting the line
* into the linked list
*/
errorCode = parseLine(argv[1], &list->head);
if (errorCode)
printError(errorCode);
else
{
draw(&list->head); /* Main loop of the program */
}
freeList(&list->head);
free(list);
}
return 0;
}