#include<stdio.h>
#include<stdlib.h>
int main()
{
int *addr, random, lower, upper, choice, count;
FILE *f1ptr, *f2ptr;
f1ptr = fopen("a.txt","w");
f2ptr = fopen("random.txt", "a+");
if(f1ptr == NULL || f2ptr == NULL)
{
printf("Error!");
exit(1);
}
do{
printf("\nEnter the lower and upper bound: ");
scanf("%d %d", &lower, &upper);
addr = (int *)malloc(sizeof(int));
fprintf(f1ptr, "%d", addr);
fscanf(f1ptr, "%d", &random);
fclose(f1ptr);
if(random < 0)
random *= -1;
random = (random % (upper - lower)) + lower;
printf("%d\n", random);
fprintf(f2ptr, "%d", random);
printf("Press 1 to continue or 0 to exit: ");
scanf("%d", &choice);
printf("\n");
}while(choice != 0);
fclose(f2ptr);
return 0;
}