summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-18 15:11:17 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-18 15:11:17 +0800
commitab7dad4795b96c9cb869de58eee30e90857a4f23 (patch)
tree2fbda5989d183cb02ece66939228a29b2c73cf94
parentff5416cd1fea048c83fd608c3a3634091abc2cdc (diff)
downloadk&r-exercises-ab7dad4795b96c9cb869de58eee30e90857a4f23.tar.gz
4.10
-rw-r--r--4/10.c8
1 files changed, 3 insertions, 5 deletions
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;