diff options
| author | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-12-18 15:11:17 +0800 |
|---|---|---|
| committer | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-12-18 15:11:17 +0800 |
| commit | ab7dad4795b96c9cb869de58eee30e90857a4f23 (patch) | |
| tree | 2fbda5989d183cb02ece66939228a29b2c73cf94 /4 | |
| parent | ff5416cd1fea048c83fd608c3a3634091abc2cdc (diff) | |
| download | k&r-exercises-ab7dad4795b96c9cb869de58eee30e90857a4f23.tar.gz | |
4.10
Diffstat (limited to '4')
| -rw-r--r-- | 4/10.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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; |
