2013-12-06 13:47:22 -05:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include <brados/string.h>
|
|
|
|
|
2014-01-31 16:12:04 -05:00
|
|
|
// Find the first instance of c in str
|
|
|
|
// Returns -1 if c is not found
|
|
|
|
int strindexof(char c, const char *str)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < strlen(str); i++) {
|
|
|
|
if (str[i] == c)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:47:22 -05:00
|
|
|
// Find the length of a string
|
|
|
|
size_t strlen(const char *str)
|
|
|
|
{
|
|
|
|
size_t len = 0;
|
|
|
|
while (str[len] != 0)
|
|
|
|
len++;
|
|
|
|
return len;
|
|
|
|
}
|