X-Git-Url: https://piware.de/gitweb/?p=learn-rust.git;a=blobdiff_plain;f=call-rust-from-c%2Fsrc%2Fmain.c;h=a8f7dbcc4816e951bc91ce10b6e4ccd19e0290e2;hp=b514433ce6fc8d680ffa67b9090ee60ed6afdb9a;hb=8c240f514e17c9a935f5f392e6a87779ae1c09e8;hpb=7ed2d982ac15df78e852fd5835d137881536a4ef diff --git a/call-rust-from-c/src/main.c b/call-rust-from-c/src/main.c index b514433..a8f7dbc 100644 --- a/call-rust-from-c/src/main.c +++ b/call-rust-from-c/src/main.c @@ -3,6 +3,20 @@ int main() { + const char *hello = "hello"; + const char *haystack = "Hello\nworld\ncan you tell?"; + printf("The answer: %i\n", answer()); + printf("Length of '%s': %u\n", hello, r_strlen(hello)); + + const unsigned char **strs = r_strlist(); + for (const unsigned char **s = strs; *s; s++) + printf("returned string array element: %s\n", *s); + free (strs); + + const char **matches = r_grep("ell", "Hello\nworld\ncan you tell?"); + for (const char **m = matches; *m; m++) + printf("matched line: %s\n", *m); + free (matches); return 0; }