I need some random numbers in my C program. Here a small example:

////////////////////////////////////////////////////////////////////////////////
#include <R.h>

void rand (int* n)
{
  int len = *n;
  for (int i = 0; i < len; i++)
    Rprintf("%1.5f ", unif_rand());
}

dyn.load("rand.dll")
.C("rand", as.integer(10))
dyn.unload("rand.dll")
////////////////////////////////////////////////////////////////////////////////

But this gives me 10 times the number 0.00000 (I need 10 numbers between 0
and 1). Can somebody give me a hint what I'm doing wrong (or misunderstand).

Thanks in advance

Thomas

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to