[R] .C interface and Strings...

From: Stephane Cruveiller <scruveil_at_genoscope.cns.fr>
Date: Fri 12 Jan 2007 - 10:15:03 GMT

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:


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:


void displaystring(char *str)


        Rprintf("String displayed:%s\n", ????);     }

any hints?



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@genoscope.cns.fr ,scruvell@infobiogen.fr

______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Received on Fri Jan 12 21:27:20 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 12 Jan 2007 - 13:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.