24 lines
447 B
C
24 lines
447 B
C
#include <string.h>
|
|
|
|
size_t strlen (const char *str)
|
|
{
|
|
size_t i;
|
|
for (i = 0; *str!=0; str++) i++;
|
|
return i;
|
|
}
|
|
|
|
int strcmp(const char *pStr1, const char *pStr2)
|
|
{
|
|
char c1, c2;
|
|
int v;
|
|
|
|
do {
|
|
c1 = *pStr1++;
|
|
c2 = *pStr2++;
|
|
/* the casts are necessary when pStr1 is shorter & char is signed */
|
|
v = (unsigned int)c1 - (unsigned int)c2;
|
|
} while ((v == 0) && (c1 != '\0'));
|
|
|
|
return v;
|
|
}
|