mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
string: strnlen
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
size_t strlen(const char *str);
|
||||
size_t strnlen(const char *str, size_t max);
|
||||
char *strcpy(char *dest, const char *src);
|
||||
char *strcat(char *dest, const char *str);
|
||||
void *memcpy(void *dest, const void *src, size_t size);
|
||||
|
||||
@@ -65,6 +65,15 @@ size_t strlen(const char *a) {
|
||||
return s;
|
||||
}
|
||||
|
||||
size_t strnlen(const char *a, size_t max) {
|
||||
size_t s = 0;
|
||||
|
||||
while (s < max && a[s] != '\0')
|
||||
++s;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int strncmp(const char *a, const char *b, size_t c) {
|
||||
int diff = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user