Hi, On Wed, Mar 23, 2011 at 8:12 PM, Jaimin Dave <davejaim...@gmail.com> wrote: > Hi, > I am new to R and I want to know how to use C code which contains two > functions one called inside another.I know that how to use C code in R if it > has only one function but dont know how to do it in above case.
There's no special case to consider here. You would call the "outer" C function from R, and let your C function call whatever other C functions it wants, ie: > use the same in R .My C code is as follows. > > //#include <R.h> > > void sayHello(); > > void g(); > > > > void sayhello() { > > Rprintf("Hello world %d\n",global); > > } > > void g() > > { > > int a=9; > > int b=1; > > Rprintf("Hello world\n %d",(a+b)); > > sayHello(); > > } > > Help would be greatly appreciated Assuming you set up your R <--> C stuff correctly, you'd just have R call your `g` function. I don't see where you have the `global` variable defined (it's used in your `sayHello` function) so this will fail for other reasons, but assuming all of your C stuff is works, then just having R call `g` correctly will work for you. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact ______________________________________________ R-help@r-project.org 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.