summaryrefslogtreecommitdiffstats
path: root/4
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-07 18:33:22 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-07 18:33:22 +0800
commit8bdf87a53e221091f76227299e6864c87ec75bf2 (patch)
treec7033575c149510e0af6cbb98b3ee42d39eb9acf /4
parentbd9550e2e7f2484ccbd6f9c6d1d2a520dbddc82c (diff)
downloadk&r-exercises-8bdf87a53e221091f76227299e6864c87ec75bf2.tar.gz
4.3
Diffstat (limited to '4')
-rw-r--r--4/3.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/4/3.c b/4/3.c
index d5810a9..83a45a9 100644
--- a/4/3.c
+++ b/4/3.c
@@ -98,7 +98,7 @@ int getop(char s[]) {
;
s[1] = 0;
- if (!isdigit(c) && c != '.')
+ if (!isdigit(c) && c != '.' && c != '-')
return c;
i = 0;
@@ -108,6 +108,9 @@ int getop(char s[]) {
if (c == '.')
while (isdigit(s[++i] = c = getch()))
;
+ if (c == '-')
+ while (isdigit(s[++i] = c = getch()))
+ ;
s[i] = 0;
if (c != EOF)