1 /* 2 * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT license. 4 */ 5 6 7 #include <string.h> 8 9 10 int 11 strncmp(char const *a, char const *b, size_t count) 12 { 13 while (count-- > 0) { 14 int cmp = (unsigned char)*a - (unsigned char)*b++; 15 if (cmp != 0 || *a++ == '\0') 16 return cmp; 17 } 18 19 return 0; 20 } 21