summaryrefslogtreecommitdiffstats
path: root/5/6.c
diff options
context:
space:
mode:
Diffstat (limited to '5/6.c')
-rw-r--r--5/6.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/5/6.c b/5/6.c
index 56fe733..d33af6c 100644
--- a/5/6.c
+++ b/5/6.c
@@ -6,7 +6,7 @@ int mgetline(char *s, int lim) {
for (i = 0; i < lim - 1 && (*s++ = getchar()) != EOF && *s != '\n'; i++)
;
-
+
if (*s == EOF)
*s = 0;
else {
@@ -15,4 +15,13 @@ int mgetline(char *s, int lim) {
}
return i;
+}
+
+int matoi(char *s) {
+ int n;
+
+ while (*s >= '0' && *s <= '9')
+ n = 10 * n + (*s++ - '0');
+
+ return n;
} \ No newline at end of file