Skip to content

Instantly share code, notes, and snippets.

@ForTheYin
ForTheYin / mem_random_v2.c
Created June 19, 2014 18:47
Memory Random (version 2)
#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;
@ForTheYin
ForTheYin / mem_random.c
Last active August 29, 2015 14:02
Memory Random (mem_random)
#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;