Hi I imported a c function who take a char array as argument. I pass a Nim 
string to it but the 3 first characters aren't expected, like this one "|" and 
random special chars who can't be displayed by the forum.

Code example
    
    
    import streams
    
    #import the c function.
    proc print_string*(input_string:string, size:int) {.header: "cfunction.h", 
importc:"print_string".}
    
    #get the text.
    var testString:string = readAll(newFileStream("testfile"))
    
    #call the function imported from c file.
    print_string(testString, testString.len())
    

And the c function, it's a dumb example who displays the problem.
    
    
    void print_string(const char input_string[], int size)
    {
            int i;
            for (i = 0; i < size; i++)
            {
                    printf("%c", input_string[i]);
            }
    }
    

Sorry for my ignorance and thanks in advance for your help.

Reply via email to