Hi there. Let me start by saying I have only been doing C for about 10 weeks, and I'm struggling to get the hang of it, so please be patient with me. Also, although this is part of a homework assignment, my professor is very aware of my coming to the boards for assistance and is supportive of this.
This project is similar to a lotto game. It prompts the user for the number of games that the user would like to run this program for. Each game prints out six random numbers in ascending order for the user (quick pick), and then generates another 6 random numbers as the winning numbers.
The problem is that the program does not want to run the two function calls. I can do the program once if I'm using an "if" statement for "do you want to play? (y/n)" with no problems, so I know the number generator and sorter works. I just can't get it to run the whole thing a given number of times. Any assistance would be appreciative. **And please, an explaination of the offered suggestions would really help me to get the hang of this.** I hate being so dependant and ignorant. Thanks in advance.
Code:#include <stdio.h> #include <stdlib.h> #include<string.h> #include<ctype.h> #include<time.h> void userGenerator(); void computerGenerator(); void printarray(int * arrpt); int main(void) { char start; int numPlay=0; int counter=numPlay; printf(" Welcome to the lotto game!!\n\n"); printf("This game asks for the number of times you would like\n"); printf("to print 6 random numbers (quick pick lotto) in ascending order\n"); printf("for you and then 6 more random numbers (winning numbers)for you to compare.\n\n"); printf("How many games would you like to play? "); scanf("%d", &numPlay); for( counter; counter > 0; counter--) { void userGenerator(); void computerGenerator(); } system("PAUSE"); return 0; } //end main void userGenerator() { int array[6]={0}; int arrlen; srand(time(NULL)); arrlen = sizeof(array)/sizeof(int); for(int x=0; x < arrlen; x++ ) { array[x] = (int) rand()%53+1; for(int y=0; y<x; y++) { if (array[y] == array[x]) { array[x] = (int) rand()%53+1; y=0; } //if() } //for (y) } //for (x) // sort array using swap and bubbles for(int y=0; y < arrlen-1; y++ ) { for(int x=0; x < arrlen-1; x++ ) { if (array[x] > array[x+1]) { int temp; temp = array[x]; array[x] = array [x+1]; array [x+1] =temp; } // } // } // printf("The random winning numbers are: "); printarray(array); } // end generator void computerGenerator() { int array[6]={0}; int arrlen; srand(time(NULL)); arrlen = sizeof(array)/sizeof(int); for(int x=0; x < arrlen; x++ ) { array[x] = (int) rand()%53+1; for(int y=0; y<x; y++) { if (array[y] == array[x]) { array[x] = (int) rand()%53+1; y=0; } //if() } //for (y) } //for (x) // sort array using swap and bubbles for(int y=0; y < arrlen-1; y++ ) { for(int x=0; x < arrlen-1; x++ ) { if (array[x] > array[x+1]) { int temp; temp = array[x]; array[x] = array [x+1]; array [x+1] =temp; } // } // } // printf("The computer comparison numbers are: "); printarray(array); } // end generator void printarray(int*arrpt) { for (int x=0; x<6; x++) { printf("%d ", arrpt[x]); } printf("\n\n"); } // end printarray