I am getting a crash when trying to use initstate_r:
The code:
I asked this on SO a while ago but it wasn't solved: http://stackoverflow.com/questions/4167034/c-initstate-r-crashing
Quote:
(gdb) run
Starting program: /home/user/test.out
Program received signal SIGSEGV, Segmentation fault.
0x40052d00 in initstate_r () from /lib/libc.so.6
(gdb) run
Starting program: /home/user/test.out
Program received signal SIGSEGV, Segmentation fault.
0x40052d00 in initstate_r () from /lib/libc.so.6
The code:
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define STATELEN 256 /* random number state buffer */
main()
{
char randomStateBuffer[STATELEN];
struct random_data randData;
printf("Before initstate");
/* seed the random number generator */
initstate_r (time(NULL), (char *)&randomStateBuffer, STATELEN,
(struct random_data *)&randData);
printf("initstate done");
}I asked this on SO a while ago but it wasn't solved: http://stackoverflow.com/questions/4167034/c-initstate-r-crashing