Parsing commandline arguments
This commit is contained in:
@ -111,3 +111,22 @@ char *string_strchr(const char *s, int c) {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/32560167/strncmp-implementation
|
||||
int string_strncmp( const char * s1, const char * s2, size_t n )
|
||||
{
|
||||
while ( n && *s1 && ( *s1 == *s2 ) )
|
||||
{
|
||||
++s1;
|
||||
++s2;
|
||||
--n;
|
||||
}
|
||||
if ( n == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( *(unsigned char *)s1 - *(unsigned char *)s2 );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user