Skip to content

Commit c46cf51

Browse files
committed
Added some more useful standard library functions.
1 parent 4b2a5f9 commit c46cf51

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/string.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,29 @@
2626
#include <stddef.h>
2727
#include <string.h>
2828

29+
int islower(int c)
30+
{
31+
return (c >= 'a' && c <= 'z');
32+
}
33+
2934
int isupper(int c)
3035
{
3136
return (c >= 'A' && c <= 'Z');
3237
}
3338

3439
int tolower(int c)
3540
{
36-
return isupper(c) ? (c) - 'A' + 'a' : c;
41+
return isupper(c) ? c - 'A' + 'a' : c;
42+
}
43+
44+
int toupper(int c)
45+
{
46+
return islower(c) ? c - 'a' + 'A' : c;
47+
}
48+
49+
int isalpha(int c)
50+
{
51+
return (isupper(c) || islower(c));
3752
}
3853

3954
void *memset(void *s, int c, size_t n)

0 commit comments

Comments
 (0)