void foo(int* data) {
for(int i = 0; i < 4; i++)
data[i] = 0;
}
However, trying to do something equivalent in Nimrod yields a type mismatch error:
var
data: array[0..8, int]
proc print(da: pointer) =
for i in countup(0, 8):
echo($da[i])
Interfacing with C arrays is a bit cumbersome. This prototype:
void vector_add(int* a, int* b, int n);
Can be accessed with:
proc vector_add(a, b: ptr cint, n: cint) {.importc, cdecl.}
template `:-/`(x: expr): expr = cast[ptr type(x[0])](addr x)
var x, y: array[0..10, cint]
vector_add( :-/x, :-/y, x.len)
PS: Couldn't resist the temptation to show off some of Nimrod's features.