Thanks again cdome.

I have another question with C but I want to avoid polluting the homepage with 
noobish topics. And strings are kind of sequence isn't it  ?

I want to pass a sequence to a C function but the result is unexpected.

Two files for minimal example.
    
    
    proc print_array(tabl:seq, size:cint) {.header:"function.h" , importc.}
    
    var test = @[
           -0.5f64, -0.5, 0.0,
            0.0, 65.2, 0.0,
            0.5, -0.5, 2564.5684
            ]
    
    print_array(test, cint(test.len()))
    
    
    
    
    // no header guard for conciseness.
    
    #include <stdio.h>
    
    void print_array(float arrTest[], int size)
    {
        int i;
        for (i= 0; i < size; i++)
            printf("test[%i]: %f \n", i, arrTest[i]);
    }
    
    

output 
    
    
    test[0]: 0.000000
    test[1]: 0.000000
    test[2]: 0.000000
    test[3]: 0.000000
    test[4]: 0.000000
    test[5]: -1.750000
    test[6]: 0.000000
    test[7]: -1.750000
    test[8]: 0.000000
    
    

I trying many stupid things whithout success. Surely a lack of understanding 
about what I'm doing.

Reply via email to