Use another language to call a function: Difference between revisions
Content added Content deleted
(Add Rust implementation) |
(Updated to work with Nim 1.4: replaced ".. <text.len" with ".. text.high". Changed compilation command for C.) |
||
Line 1,028: | Line 1,028: | ||
return 0 |
return 0 |
||
for i in 0 .. |
for i in 0 .. text.high: |
||
data[i] = text[i] |
data[i] = text[i] |
||
length = text.len |
length = text.len |
||
Line 1,053: | Line 1,053: | ||
} |
} |
||
}</lang> |
}</lang> |
||
Compile the above with <code>gcc -ldl -o main main.c libquery |
Compile the above with <code>gcc -ldl -o main main.c libquery.a</code>, then execute the resulting <code>main</code> binary: |
||
<pre>./main |
<pre>./main |
||
Here am I |
Here am I |