From e4baba24a4c30ea7162d54711e39e0b457515d88 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Mon, 6 Feb 2023 12:18:59 -0800 Subject: i forgot what i updated --- README | 3 ++- snake.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README b/README index c1a7668..fb0625b 100644 --- a/README +++ b/README @@ -3,7 +3,8 @@ Snake3 This is a simple snake game written in C. It is written without ncurses or curses, and instead relies entirely -on the termios library. +on the termios library. It completely conforms to C99 +ISO standards. May be networked in the future. diff --git a/snake.c b/snake.c index 5a021a5..c57530d 100644 --- a/snake.c +++ b/snake.c @@ -25,7 +25,6 @@ vector_t foodPos; vector_t lastMoveDir; void interrupt_handler(int sig); // passed into signal(3) to handle ctrl-c interrupts - //unsafe functions like printf cannot be called in async interrupt handler void interrupt_handler(int sig) { UNUSED(sig); @@ -33,7 +32,8 @@ void interrupt_handler(int sig) { } int main(int argc, char **argv) { - for (int i = 0; i < argc; i ++) { + /* parsing arguments */ + for (int i = 1; i < argc; i ++) { if (strcmp("--version", argv[i]) == 0) { printf("snake3, version 1.0\n"); printf("Copyright 2023 Kai Stevenson\n"); @@ -43,8 +43,12 @@ int main(int argc, char **argv) { } else if (strcmp("--help", argv[i]) == 0) { printf("usage: snake3 [--version] [--help]\n"); return 0; + } else { + printf("usage: snake3 [--version] [--help]\n"); + return 1; } } + //get terminal size struct winsize win; ioctl(fileno(stdout), TIOCGWINSZ, &win); -- cgit v1.3.1