[R] .C interface and Strings...

Stephane Cruveiller scruveil at genoscope.cns.fr
Fri Jan 12 11:15:03 CET 2007


Dear R users,

I am trying to include C code into R via the .C interface.  I have read
that arguments passed to a C function have to be correctly DEreferenced.
This is something that can be easily done for numbers (integers or 
float) by adding
a * before the reference like for instance:

------------------------------------------------------------------------
 #include<R.h>


void hellofct(int *n)
    {
        int i;
        for (i=0;i<*n;i++)
            {
                Rprintf("Hello, world!\n");
            }
    }
------------------------------------------------------------------------  

However, I can not figure out how that can be achieved for strings.
My prototype function would be something like:

------------------------------------------------------------------------
 #include<R.h>


void displaystring(char *str)
    {
        Rprintf("String displayed:%s\n", ????);
    }
------------------------------------------------------------------------  

any hints?

Thx.

Stéphane.

-- 
==========================================================
Stephane CRUVEILLER Ph. D.
Genoscope - Centre National de Sequencage
Atelier de Genomique Comparative
2, Rue Gaston Cremieux   CP 5706
91057 Evry Cedex - France
Phone: +33 (0)1 60 87 84 58
Fax: +33 (0)1 60 87 25 14
EMails: scruveil at genoscope.cns.fr ,scruvell at infobiogen.fr
===========================================================



More information about the R-help mailing list