]> Devi Nivas Git - cs3210-lab0.git/commitdiff
atoi, for kill
authorrsc <rsc>
Wed, 8 Aug 2007 08:56:09 +0000 (08:56 +0000)
committerrsc <rsc>
Wed, 8 Aug 2007 08:56:09 +0000 (08:56 +0000)
ulib.c
user.h

diff --git a/ulib.c b/ulib.c
index decab69dbda5d2bd6edf89aed805f015b49f857c..ce4e13d13bbfbabad5422e36e0c0d9b8d0ba660e 100644 (file)
--- a/ulib.c
+++ b/ulib.c
@@ -88,3 +88,14 @@ stat(char *n, struct stat *st)
   close(fd);
   return r;
 }
+
+int
+atoi(const char *s)
+{
+  int n;
+
+  n = 0;
+  while('0' <= *s && *s <= '9')
+    n = n*10 + *s++ - '0';
+  return n;
+}
diff --git a/user.h b/user.h
index bda6e6cf17f0ca7cb30f6efd0d34f4c8f197e1d9..1bd512d6431d6527036bccae7a4c7239113a074e 100644 (file)
--- a/user.h
+++ b/user.h
@@ -31,3 +31,4 @@ unsigned int strlen(char*);
 void* memset(void*, int, unsigned int);
 void* malloc(uint);
 void free(void*);
+int atoi(const char*);