3 ms·
Some string operations written in C from the lib, funny to see these and how ubiquitous they still are: /* * @(#)strops.c 1.1 92/07/30 Copyr 1985 Sun Micro *
by ldjkfkdsjnv 4y ago
Some string operations written in C from the lib, funny to see these and how ubiquitous they still are:
/*
* @(#)strops.c 1.1 92/07/30 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);
}