summaryrefslogtreecommitdiff
path: root/lib/mystring/find_first_ch.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mystring/find_first_ch.cc')
-rw-r--r--lib/mystring/find_first_ch.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/mystring/find_first_ch.cc b/lib/mystring/find_first_ch.cc
new file mode 100644
index 0000000..0a652d0
--- /dev/null
+++ b/lib/mystring/find_first_ch.cc
@@ -0,0 +1,11 @@
+#include "mystring.h"
+#include <string.h>
+
+int mystring::find_first(char ch, size_t offset) const
+{
+ if(offset >= rep->length)
+ return -1;
+ char* ptr = strchr(rep->buf+offset, ch);
+ return ptr ? ptr-rep->buf : -1;
+}
+