source: buchla-68k/libsm/strncmp.c@ 0580615

Last change on this file since 0580615 was 0580615, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Point of no return.

  • Property mode set to 100644
File size: 490 bytes
Line 
1/*
2 =============================================================================
3 strncmp.c -- compare strings
4 Version 2 -- 1987-06-15
5
6 Compare strings (at most n bytes)
7 Returns: s1>s2; >0 s1==s2; 0 s1<s2; <0
8 =============================================================================
9*/
10
11int strncmp(char *s1, char *s2, int n)
12{
13 if (s1 == s2)
14 return(0);
15
16 while ((--n >= 0) && (*s1 == *s2++))
17 if(*s1++ == '\0')
18 return(0);
19
20 return((n < 0) ? 0 : (int)(*s1 - *--s2));
21}
Note: See TracBrowser for help on using the repository browser.