diff options
| author | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-12-21 18:40:24 +0800 |
|---|---|---|
| committer | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-12-21 18:40:24 +0800 |
| commit | fa3299b4d7e305cbd5f29e12c69227182fc2f924 (patch) | |
| tree | 2a363365b6a6fef0a07ceb8d86191eaf32c1331d /4 | |
| parent | 81b3b08c46f906e1969334975636f8cdb4dad464 (diff) | |
| download | k&r-exercises-fa3299b4d7e305cbd5f29e12c69227182fc2f924.tar.gz | |
4.11
Diffstat (limited to '4')
| -rw-r--r-- | 4/11.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -14,7 +14,7 @@ #define INDEX(x) (x <= 'Z' ? x - 'A' : x - 71) /* index of the variable */ -char var[52]; +double var[52]; double lout = 0.0; void clear(); @@ -148,15 +148,20 @@ int getop(char s[]) { ; pc = c; rc = i == 1 && s[0] == '-' ? '-' : NUM; - } else if (isalpha(c) && getch() == '=') { - s[++i] = c; - rc = '='; } else { while (isalnum(s[++i] = c = getch())) ; s[i] = 0; pc = c; - rc = strcmp("LOUT", s) == 0 || strlen(s) == 1 ? VAR : FUN; + if (c == ' ') { + if ((c = getch()) == '=') + rc = '='; + else { + pc = c; + rc = strcmp("LOUT", s) == 0 || strlen(s) == 1 ? VAR : FUN; + } + } else + rc = strcmp("LOUT", s) == 0 || strlen(s) == 1 ? VAR : FUN; } s[i] = 0; |
