aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/misc.c15
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;
+}