Doom port #21
@@ -14,5 +14,6 @@ char *strcat(char *dest, const char *src);
|
||||
void strncpy(char* dst, const char* src, size_t n);
|
||||
int strncmp(const char* s1, const char* s2, size_t n);
|
||||
size_t strlen(const char* str);
|
||||
int atoi(const char* str);
|
||||
|
||||
#endif
|
||||
+27
-2
@@ -71,7 +71,6 @@ void strncpy(char* dst, const char* src, size_t n)
|
||||
while(i++ != n && (*dst++ = *src++));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* strncmp - compare two strings up to n characters
|
||||
* @s1: first string
|
||||
@@ -100,10 +99,36 @@ int strncmp(const char* s1, const char* s2, size_t n)
|
||||
}
|
||||
}
|
||||
|
||||
// BSD implementation
|
||||
/*
|
||||
* strlen - get length of a string (BSD implementation)
|
||||
* @str: NULL-terminated string
|
||||
*
|
||||
* Return:
|
||||
* %len - length of string
|
||||
*/
|
||||
size_t strlen(const char* str)
|
||||
{
|
||||
const char* s;
|
||||
for (s = str; *s; ++s);
|
||||
return (s - str);
|
||||
}
|
||||
|
||||
/*
|
||||
* atoi - ascii to integer (PureDOOM implementation)
|
||||
* @str: ASCII string to convert
|
||||
*
|
||||
* Return:
|
||||
* %i - integer represented in @str
|
||||
*/
|
||||
int atoi(const char* str)
|
||||
{
|
||||
int i = 0;
|
||||
int c;
|
||||
|
||||
while ((c = *str++) != 0) {
|
||||
i *= 10;
|
||||
i += c - '0';
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
Reference in New Issue
Block a user