Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*test.c */
- #include <stdio.h>
- #include <string.h>
- int count(char *String)
- {
- return strlen(String);
- }
- int count_char(char *String, char toSearch)
- {
- int i, count;
- count = 0;
- i=0;
- while(String[i] != '\0')
- {
- /*
- * If character is found in string then
- * increment count variable
- */
- if(String[i] == toSearch)
- {
- count++;
- }
- i++;
- }
- return count;
- }
- # Raku code
- use NativeCall;
- sub count(Str) returns int32 is native('libtest') { * };
- sub count_char(Str, Str) returns int32 is native('libtest') { * };
- say count("nativecall");
- say count_char("nativecall", "a")
- # While count works , count_char doesn't. How can I make it work?
- # I am in windows 10, and the dynamic library generated is libtest.dll
Add Comment
Please, Sign In to add comment