summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-18 15:10:16 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-18 15:10:16 +0800
commitff5416cd1fea048c83fd608c3a3634091abc2cdc (patch)
treeef80363339788354ec09df5e6ef2e9123a0c7d3a
parenta7dc7475b5b2ef5e4e4cd547581ccb11a13f6a95 (diff)
downloadk&r-exercises-ff5416cd1fea048c83fd608c3a3634091abc2cdc.tar.gz
4.10
-rw-r--r--4/10.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/4/10.c b/4/10.c
index f4946ce..6297ee1 100644
--- a/4/10.c
+++ b/4/10.c
@@ -34,7 +34,8 @@ int getop(char[]);
- press enter to print the value at the top of the stack.
*/
int main(int argc, char *argv[]) {
- int type, op1, op2;
+ int type;
+ double op1, op2;
char s[MAXOP];
while (mgetline()) {
@@ -153,9 +154,8 @@ int getop(char s[]) {
i = 0;
- if (isdigit(c) || c == '-' || (c == '.' && isdigit(line[idx + 1]))) {
- while (isdigit((s[++i] = c = line[idx++])) ||
- (c == '.' && isdigit(line[idx + 1])))
+ if (isdigit(c) || c == '-' || c == '.') {
+ while (isdigit((s[++i] = c = line[idx++])) || c == '.')
;
idx--;
rc = NUM;