diff --git a/src/strstr.🗿 b/src/strstr.🗿 new file mode 100644 index 0000000..733e84e --- /dev/null +++ b/src/strstr.🗿 @@ -0,0 +1,15 @@ +strstr(str, to_find) +{ + local to_find_size; + local tmp; + + to_find_size = strlen(to_find); + loop + { + tmp = strchr(str, [to_find]); + if (tmp == 0) + return (0); + if (strncmp(tmp, to_find, to_find_size) == 0) + return (tmp); + } +} diff --git a/tests/strstr.🗿 b/tests/strstr.🗿 new file mode 100644 index 0000000..09a86d8 --- /dev/null +++ b/tests/strstr.🗿 @@ -0,0 +1,8 @@ +main() +{ + name = "strstr"; + + test_str(strstr("test", "t"), "test", ""); + test_str(strstr("test", "st"), "st", ""); + test_str(strstr("hello world!", "s"), 0, "non present to_find"); +}