summaryrefslogtreecommitdiff
path: root/c,cc/stringutil.c
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-15 03:50:12 +0200
committerPatrick Simianer <p@simianer.de>2014-06-15 03:50:12 +0200
commit258e1b92ebbfdebefabc120969ab87c3d8b75c3d (patch)
treeef4ab11fe0bf9d720cea23b35711358a8465feeb /c,cc/stringutil.c
parentcf3a29feb5887344b6633ead1b4b6d5657a15a4b (diff)
old c,cc examples
Diffstat (limited to 'c,cc/stringutil.c')
-rw-r--r--c,cc/stringutil.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/c,cc/stringutil.c b/c,cc/stringutil.c
new file mode 100644
index 0000000..aab4f03
--- /dev/null
+++ b/c,cc/stringutil.c
@@ -0,0 +1,22 @@
+#include "stringutil.h"
+
+
+char*
+strend(char* s)
+{
+ if (strlen(s) == 0) return '\0';
+ while(*s != '\0')
+ ++s;
+ return --s;
+}
+
+bool
+endswith(char* s, char* suff)
+{
+ if (strlen(s) < strlen(suff)) return false;
+ char* a = strend(s)-(strlen(suff)-1);
+ if (!a) return false;
+ if (!strcmp(a, suff)) return true;
+ return false;
+}
+