Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string add indexOf and lastIndexOf function #135

Open
jsbxyyx opened this issue Mar 27, 2025 · 3 comments
Open

string add indexOf and lastIndexOf function #135

jsbxyyx opened this issue Mar 27, 2025 · 3 comments

Comments

@jsbxyyx
Copy link

jsbxyyx commented Mar 27, 2025

op string function

string indexOf(string str, string substr, int fromIndex)

string lastIndexOf(string str, string substr, int fromIndex)
@tezc
Copy link
Owner

tezc commented Mar 27, 2025

probably you can do it with strstr(), no? something like strstr(str + fromIndex, substr)

@jsbxyyx
Copy link
Author

jsbxyyx commented Mar 27, 2025

int indexOf(string str, string substr, int fromIndex)

int lastIndexOf(string str, string substr, int fromIndex)

I'm describe error. return value type is int.

@tezc
Copy link
Owner

tezc commented Mar 29, 2025

/* Returns a pointer to the beginning of the located substring.
   Returns NULL if the substring is not found or 'fromIndex' is larger than the length of str */
char *sc_str_indexof(const char *str, const char *needle, uint32_t fromIndex, int reverse);

maybe we can do something like this, similar to strstr(), it may return located string position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants