]> pd.if.org Git - pdclib.old/blobdiff - functions/string/strncmp.c
Added some of <string.h>.
[pdclib.old] / functions / string / strncmp.c
diff --git a/functions/string/strncmp.c b/functions/string/strncmp.c
new file mode 100644 (file)
index 0000000..f64984e
--- /dev/null
@@ -0,0 +1,29 @@
+/* $Id$ */
+
+/* Release $Name$ */
+
+/* strncmp( const char *, const char *, size_t )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <string.h>
+
+int strncmp( const char * s1, const char * s2, size_t n )
+{
+    while ( n && ( *s1 == *s2 ) )
+    {
+        ++s1;
+        ++s2;
+        --n;
+    }
+    if ( ( n == 0 ) )
+    {
+        return 0;
+    }
+    else
+    {
+        return ( *s1 - *s2 );
+    }
+}