rendered paste body#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* Program for creating a sudoku */
/* Seed the rand() function */
void plant_seed()
{
time_t Seconds;
time(&Seconds);
srand((unsigned int) Seconds);
}
int get_urandom(FILE *fp)
{
int rnd;
fread(&rnd, sizeof(int), 1, fp);
rnd=(rnd % 5)+5;
return rnd;
}
void fill_grid(int *grid)
{
int y;
int x;
FILE *fp = fopen("/dev/urandom", "r");
plant_seed();
for ( y = 0; y < 9; y++ )
{
for ( x = 0; x < 9; x++ )
{
grid[y][x]=get_urandom(fp);
}
}
}
int main()
{
int grid[9][9];
fill_grid(*grid);
int y;
int x;
for ( y = 0; y < 9; y++ )
{
for ( x = 0; x < 9; x++ )
{
printf( "%i", grid[y][x] );
}
printf( "\n" );
}
}