33 lines
436 B
C
33 lines
436 B
C
/*
|
|
* @(#)strops.c 1.1 94/10/31 Copyr 1985 Sun Micro
|
|
* Assorted string operations
|
|
*/
|
|
|
|
/*
|
|
* Compare strings: s1>s2: >0 s1==s2: 0 s1<s2: <0
|
|
*/
|
|
strcmp(s1, s2)
|
|
register char *s1, *s2;
|
|
{
|
|
|
|
while (*s1 == *s2++)
|
|
if (*s1++=='\0')
|
|
return (0);
|
|
return (*s1 - *--s2);
|
|
}
|
|
|
|
/*
|
|
* Returns the number of
|
|
* non-NULL bytes in string argument.
|
|
*/
|
|
strlen(s)
|
|
register char *s;
|
|
{
|
|
register int n;
|
|
|
|
n = 0;
|
|
while (*s++)
|
|
n++;
|
|
return (n);
|
|
}
|