This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// returns a random number, less segfaults, slower though | |
int mem_random(int seed, int sprout){ | |
// now the seed pointer is the size of a integer and float! | |
int* seed_ptr = (int*) malloc(sizeof(int) + sizeof(float)); | |
// set the first part to the seed | |
*seed_ptr = seed; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// returns a random number | |
int mem_random(int seed){ | |
int* seed_ptr = (int*) malloc(sizeof(int)); | |
*seed_ptr = seed; | |
// shift the pointer by some amount, should point to something random | |
void* random_ptr = ((char*)seed_ptr) + 1; |