From ab7dad4795b96c9cb869de58eee30e90857a4f23 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sat, 18 Dec 2021 15:11:17 +0800 Subject: 4.10 --- 4/10.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to '4/10.c') diff --git a/4/10.c b/4/10.c index 6297ee1..83a9053 100644 --- a/4/10.c +++ b/4/10.c @@ -129,13 +129,12 @@ int line[MAXLINE]; int mgetline() { int i, c; - for (i = 0; i < MAXLINE - 1 && (c = getchar()) != '\n' && c != EOF; i++) { + for (i = 0; i < MAXLINE - 1 && (c = getchar()) != '\n' && c != EOF; i++) line[i] = c; - } line[i++] = '\n'; line[i] = 0; - idx = 0; + idx = 0; return c == EOF ? 0 : 1; } @@ -148,9 +147,8 @@ int getop(char s[]) { // special characters and operators if (c == 0 || c == '+' || c == '*' || c == '/' || c == '%' || c == '\n' || - (c == '-' && !isdigit(line[idx + 1])) || c == EOF) { + (c == '-' && !isdigit(line[idx + 1])) || c == EOF) return c; - } i = 0; -- cgit v1.2.3