C code 
    
    
    char* get_char(int n)
    {
            char* p = (char*)malloc(sizeof(char)*n);
            printf("%p\n", p);
            strcpy(p, "hello,world,from c!");
            return p;
    }
    
    void del_char(char* p)
    {
            free((void*)p);
    }
    
    
    
    {.compile: "logic.c".}
    proc get_char(n: cint): cstring {.importc.}
    proc del_char(p: cstring){.importc.}
    
    var cs = get_char(100)
    echo cs
    cs = "I change this"
    echo cs
    del_char(cs)
    

E:CODEnim>nim c -r test.nim Hint: used config file 'd:Nimconfignim.cfg' [Conf] 
Hint: system [Processing] Hint: test [Processing] Hint: [Link] Hint: operation 
successful (10306 lines compiled; 0.361 sec total; 15.504MiB; De bug Build) 
[SuccessX]

0000000000645850

hello,world,from c!

I change this

Error: execution of an external program failed: 'e:\code\nim\test.exe '

Reply via email to