forked from starnakin/IronGOLEM
add: strstr
This commit is contained in:
parent
4f0d18ee68
commit
889006903b
15
src/strstr.🗿
Normal file
15
src/strstr.🗿
Normal file
@ -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);
|
||||
}
|
||||
}
|
8
tests/strstr.🗿
Normal file
8
tests/strstr.🗿
Normal file
@ -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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user