]> piware.de Git - learn-rust.git/blob - call-rust-from-c/src/main.c
concepts: rustfmt
[learn-rust.git] / call-rust-from-c / src / main.c
1 #include <stdio.h>
2 #include "rustlib.h"
3
4 int main()
5 {
6     const char *hello = "hello";
7     const char *haystack = "Hello\nworld\ncan you tell?";
8
9     printf("The answer: %i\n", answer());
10     printf("Length of '%s': %u\n", hello, r_strlen(hello));
11
12     const unsigned char **strs = r_strlist();
13     for (const unsigned char **s = strs; *s; s++)
14         printf("returned string array element: %s\n", *s);
15     free (strs);
16
17     const char **matches = r_grep("ell", "Hello\nworld\ncan you tell?");
18     for (const char **m = matches; *m; m++)
19         printf("matched line: %s\n", *m);
20     free (matches);
21     return 0;
22 }