summaryrefslogtreecommitdiffstats
path: root/hw4/l4basic/l4str.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw4/l4basic/l4str.c')
-rw-r--r--hw4/l4basic/l4str.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/hw4/l4basic/l4str.c b/hw4/l4basic/l4str.c
index c1f6c51..5569f7a 100644
--- a/hw4/l4basic/l4str.c
+++ b/hw4/l4basic/l4str.c
@@ -7,6 +7,22 @@
#include <stdlib.h>
#include <string.h>
+bool lbs_str_has_prefix (const char* str, const char* prefix) {
+ int i;
+ for (i = 0; str != '\0' && prefix[i] != '\0'; i++) {
+ if (str[i] != prefix[i]) {
+ return false;
+ }
+ }
+ if (str[i] == '\0' && prefix[i] == '\0') {
+ return true;
+ }
+ if (str[i] == '\0') {
+ return false;
+ }
+ return true;
+}
+
bool lbs_str_has_suffix (const char* str, const char* suffix) {
size_t len = strlen (str);
size_t suflen = strlen (suffix);