strlen(3) strnlen(3)
This commit is contained in:
parent
fd8f2bee3e
commit
4206d6dee5
17
cstdlib/string.c
Normal file
17
cstdlib/string.c
Normal file
@ -0,0 +1,17 @@
|
||||
size_t
|
||||
strlen(const char *s){
|
||||
size_t r;
|
||||
|
||||
for(r = 0; s[r] != '\0'; ++r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
size_t
|
||||
strnlen(const char *s, size_t maxlen){
|
||||
size_t r;
|
||||
|
||||
for(r = 0; s[r] != '\0' && r < maxlen; ++r);
|
||||
|
||||
return r;
|
||||
}
|
5
cstdlib/string.h
Normal file
5
cstdlib/string.h
Normal file
@ -0,0 +1,5 @@
|
||||
#ifndef _STRING_H
|
||||
# define _STRING_H
|
||||
size_t strlen(const char *s);
|
||||
size_t strnlen(const char *s, size_t maxlen);
|
||||
#endif /* ifndef _STRING_H */
|
Loading…
Reference in New Issue
Block a user