diff options
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c new file mode 100644 index 0000000..9a38e63 --- /dev/null +++ b/src/misc.c @@ -0,0 +1,15 @@ +#include <string.h> + +/* Returns the index of the first occurence of ch in str */ +int strind(const char* str, const char ch) +{ + int index = 0; + while(*str != 0 || str == NULL) + { + if(*str == ch) + break; + ++index; + ++str; + } + return index; +} |