aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Liodden <[email protected]>2017-12-04 11:22:32 +0100
committerErik Liodden <[email protected]>2017-12-04 11:22:32 +0100
commitd2ce85a97e4282a216ccd503b519174761ccd1e2 (patch)
treeccb86bff0a5dcebf9ad8fda3fff1d4c9c8fa3079
parent09a16b23b7b6cfbd98717e13867635d88df02159 (diff)
downloadalgdat-d2ce85a97e4282a216ccd503b519174761ccd1e2.tar.gz
small cleanup of oving1.c
removed redundant includes and sanity check for the input file. it is more fun to just assume that the input will be on the correct format
-rw-r--r--oving1.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/oving1.c b/oving1.c
index c7e4ef7..c504803 100644
--- a/oving1.c
+++ b/oving1.c
@@ -5,11 +5,11 @@
* Erik Liodden
*/
-#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include "structure.h"
-#include "io.h"
+
+#define BUF_SIZE 1024
int main(void)
{
@@ -21,13 +21,13 @@ int main(void)
/*read from stdin to buffer */
while (fgets(buf, BUF_SIZE, stdin)) {
- if (!(isdigit(*buf) || *buf == '-'))
- continue;
num = atoi(buf);
node = llist_create_node(sizeof(int), NULL);
llist_node_set_elem(node, &num);
llist_insert_end(&l, node);
}
+
+ /* traverse the linked list */
node = l.nil;
llist_get_elem(node->next, &max);
while ((node = node->next) != l.nil) {
@@ -36,6 +36,7 @@ int main(void)
max = num;
}
printf("%d\n", max);
+
/* free memory allocated by the list */
llist_dispose(&l);
return 0;