Ok ty. finally got it working. is there any way to imporve it?
Code:
#include <stdio.h>
#include <stdlib.h>
int GetRand(int min, int max);
int main(void)
{
int i, r, x;
for (i = 0; i < 1001; i++)
{
r = GetRand(1, 1000);
}
while (1)
{
char last;
printf("Pick a number between 1 and 1000\n");
scanf("%d", &x);
if (x < r)
{ printf("Higher than %d\n", x); }
if (x > r)
{ printf("Lower than %d\n", x); }
if (x == r)
{ printf("Correct! The correct number was %d!\n", r);
scanf("%c", &last);
return 0; }
}
}
int GetRand(int min, int max)
{
static int Init = 0;
int rc;
if (Init == 0)
{
srand(time(NULL));
Init = 1;
}
rc = (rand() % (max - min + 1) + min);
return (rc);
}