[R] .C and character
Torsten Hothorn
hothorn at amadeus.statistik.uni-dortmund.de
Thu Mar 25 18:41:22 CET 1999
On 25 Mar 1999, Douglas Bates wrote:
> >>>>> "Torsten" == Torsten Hothorn <hothorn at amadeus.statistik.uni-dortmund.de> writes:
>
> Torsten> Hi, I had a problem passing characters from R into c-code
> Torsten> by dyn.load() and .C().
>
> Torsten> test1.c: void R2Cstr(char *str) { printf("\n my char: %s
> Torsten> \n", str[0]); }
>
> You must declare str as char **str. The basic character vector in R
> is a vector of strings, not a vector of characters. Notice that the
> way you are printing it assumes that str[0] is char *, not char.
> If you change your example to
>
> test1.c:
> void R2Cstr(char **str)
> {
> printf("\n my char: %s \n", str[0]);
> }
>
> test1.R:
> dyn.load("mylib.so");
> .C("R2Cdouble", as.character("test"));
>
> it should work.
Yes, it does. Thanx very much,
Torsten
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list