I am trying to implement a random number generator
I am not using visual studies but the complier is still a c complier and i will explain any of the code that is not the standard "norm" in visual studies
so here is what i am having an issue with, is that every time i run the program at intial start up i get the same random four numbers
All i trying to do is write a function that will give me random numbers on a hex scale from 0x00 to 0xFF
so here is the code
Code:
#include "stdlib.h"
#include "time.h"
#include "string.h"
#include "stdio.h"
int num1, num2, num3, num4;
int gen_rand(void);
int randomNumber;
void main(void)
{
num1=gen_rand( );
num2=gen_rand( );
num3=gen_rand( );
num4=gen_rand( );
LCD_Position(0,0);
LCD_PrHexByte(num1);
LCD_Position(0,10);
LCD_PrHexByte(num2);
LCD_Position(1,0);
LCD_PrHexByte(num3);
LCD_Position(1,10);
LCD_PrHexByte(num3);
}
int gen_rand(void)
{
int n;
n=rand( );
return (n);
}
the lcd positon commands are just to put the random number generator in a spacific spot on the lcd and the prCHexByte is to just put the random number into a hex value so that i can use it in my project
and every time i start the program i get A6 E7 94 94
which is random, but not random enough that everyitme i start the program i get the same results
inside my my main i put a while(1) loop to just sit there and spit out random numbers but i want to program a way that everytime i call the random function i get a different value