Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

Check if String Starts with a Substring

I need to check if a string starts with a sub string but it seems like I am failing to do so :disappointed:
I tried string.startWith() but it did not work, because I found out later that JS strings is not supported in MJS.

So I tried to import a foreign function :

let startsWith = ffi('int strncmp(const char *s1, const char *s2, size_t n);');

But it gave

[Nov 12 00:01:34.347] MJS error: bad ffi signature: "int strncmp(const char *s1, const char *s2, size_t n);": failed to parse val type "const char *s1"

Any suggestions please


Sign In or Register to comment.