summaryrefslogtreecommitdiffstats
path: root/5/6.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2022-01-01 14:31:47 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2022-01-01 14:31:47 +0800
commit6fefd8c1430834879d9c65872f24d9e99efcd3f4 (patch)
treecba05366630a0374b2d8a17a86fa836967615e21 /5/6.c
parent87623211e0dbcddb4d6d62b72328c4fca4d11b36 (diff)
downloadk&r-exercises-6fefd8c1430834879d9c65872f24d9e99efcd3f4.tar.gz
5.6
Diffstat (limited to '5/6.c')
-rw-r--r--5/6.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/5/6.c b/5/6.c
index d33af6c..e151c1c 100644
--- a/5/6.c
+++ b/5/6.c
@@ -20,8 +20,8 @@ int mgetline(char *s, int lim) {
int matoi(char *s) {
int n;
- while (*s >= '0' && *s <= '9')
- n = 10 * n + (*s++ - '0');
+ for (n = 0; *s >= '0' && *s <= '9'; s++)
+ n = 10 * n + (*s - '0');
return n;
} \ No newline at end of file