strncmp.c

Go to the documentation of this file.
00001 /*
00002  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00003  * See the copyright notice in the ACK home directory, in the file "Copyright".
00004  */
00005 /* $Id: strncmp.c,v 1.1.1.1 2005/04/21 14:56:06 beng Exp $ */
00006 
00007 #include        <string.h>
00008 
00009 int
00010 strncmp(register const char *s1, register const char *s2, register size_t n)
00011 {
00012         if (n) {
00013                 do {
00014                         if (*s1 != *s2++)
00015                                 break;
00016                         if (*s1++ == '\0')
00017                                 return 0;
00018                 } while (--n > 0);
00019                 if (n > 0) {
00020                         if (*s1 == '\0') return -1;
00021                         if (*--s2 == '\0') return 1;
00022                         return (unsigned char) *s1 - (unsigned char) *s2;
00023                 }
00024         }
00025         return 0;
00026 }

Generated on Fri Apr 14 22:57:25 2006 for minix by  doxygen 1.4.6