summaryrefslogtreecommitdiffstats
path: root/4/4.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-10 19:44:06 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-10 19:44:06 +0800
commit3bda511d9ed826062176e18a285278531473253a (patch)
treece0cbe45ab4da4dbce115c5608f3c61c12db6078 /4/4.c
parenta34e1ed98dd2dd22721f2dd6fa5af06f771b403a (diff)
downloadk&r-exercises-3bda511d9ed826062176e18a285278531473253a.tar.gz
4.4
Diffstat (limited to '4/4.c')
-rw-r--r--4/4.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/4/4.c b/4/4.c
index b6b194d..0779ce0 100644
--- a/4/4.c
+++ b/4/4.c
@@ -145,13 +145,11 @@ int getop(char s[]) {
// numbers
if (isdigit(c) || c == '-') {
- if (c == '-') {
- // minus operator
- if (!isdigit(s[++i] = c = getch())) {
- ungetch(c);
- s[i] = 0;
- return '-';
- }
+ // minus operator
+ if (c == '-' && !isdigit(s[++i] = c = getch())) {
+ ungetch(c);
+ s[i] = 0;
+ return '-';
}
while (isdigit(s[++i] = c = getch()) || c == '.')