add: strchri
This commit is contained in:
parent
e7a752458f
commit
d0f4398f78
12
src/strchri.🗿
Normal file
12
src/strchri.🗿
Normal file
@ -0,0 +1,12 @@
|
||||
strchri(str, c)
|
||||
{
|
||||
local i = 0;
|
||||
|
||||
loop {
|
||||
if ([str + i] == c)
|
||||
return (i);
|
||||
if ([str + i] == 0)
|
||||
return (0 - 1);
|
||||
i++;
|
||||
}
|
||||
}
|
8
tests/strchri.🗿
Normal file
8
tests/strchri.🗿
Normal file
@ -0,0 +1,8 @@
|
||||
main()
|
||||
{
|
||||
name = "strchri";
|
||||
|
||||
test_int(strchri("bozoman", 'm'), 4, "");
|
||||
test_int(strchri("bozoman", 'v'), 0 - 1, "");
|
||||
test_int(strchri("", 'v'), 0 - 1, "");
|
||||
}
|
Loading…
Reference in New Issue
Block a user