I'm need to create a program that simulates a lottery. I've already generated the drawn numbers and the tickets and also had the user input the prize money. My question is, how can I print the tickets to a notepad file? I've been Googling for hours and can't find anything. Attached is the code I've done so far. Thanks in advance.
int draw = 4, i, money; //for drawn numbers and prize money
int n = 5, j, x, y = 10; //for generating tickets
bool arr[100] = { 0 };
time_t t;
printf("The Prize money to be won is $ ");
scanf_s("%d", &money);
printf("\n\nThe 4 drawn Numbers are: \n");
srand((unsigned)time(&t));
for (i = 0; i < draw; ++i)
{
int r = rand() % 25;
if (!arr[r])
printf("%3d ", r + 1);
}
printf("\n");
// generate tickets
printf("\n\nThe tickets are:\n");
srand((unsigned)time(&t));
for (x = 0; x < y; ++x)
{
for (j = 0; j < n; ++j)
{
int r = rand() % 25;
if (!arr[r])
printf("%3d ", r + 1);
}
printf("\n");
}
return 0;