jeudi 23 juin 2016

Identified is undefined


Recently started programming, and I have a project that is punching me in the face. I am trying to pass userPick and compPick into compare in order to find out how many numbers in the two arrays match for a lottery problem. I have a few other issues in the program that I am sorting, but passing these two functions into the third is a problem I just don't have the expertise to solve at the moment. const int SIZE = 5; void compare(int user[], int comp[]); int userPick() { int user[SIZE]; cout << "Please enter your five (5) lottery numbers.n"; cout << "Your five (5) lottery numbers must be between 0 and 9 with no duplicates!n"; for (int i = 0; i < SIZE; ++i) { cin >> user[i]; if (user[i] < 0 || user[i] > 9) { cout << "That number is not between 0 and 9. Please try again!n"; cin >> user[i]; for (int c = 0; c < i; ++c) { if (user[i] == user[c]) { cout << "You have already entered " << user[i] << ". Please enter another number!n"; cin >> user[i]; } } } return user[5]; } for (int i = 0; i < SIZE; ++i) { cout << "Your numbers are: " << user[i] << endl; } } int compPick() { srand(time(0)); int comp[SIZE]; for (int i = 0; i < SIZE; ++i) { comp[i] = rand() % 10; for (int c = 0; c < i; ++c) { if (comp[i] == comp[c]) { comp[i] = rand() % 10; } } } for (int i = 0; i < SIZE; ++i) { cout << "The lotto numbers are: " << comp[i] << endl; } return comp[5]; } int main() { userPick(); compPick(); compare(userPick(user), compPick(comp)); cout << "You got " << endl; system("Pause"); return 0; } int compare(int *user[], int *comp[]) { int c = 0; int credit = 0; for (int i = 0; i < SIZE; ++i) { if (user[i] == comp[c]) { credit += 1; i = SIZE; c += 1; for (int i = 0; i < SIZE; ++i) { if (user[i] == comp[c]) { credit += 1; i = SIZE; c += 1; for (int i = 0; i < SIZE; ++i) { if (user[i] == comp[c]) { credit += 1; i = SIZE; c += 1; for (int i = 0; i < SIZE; ++i) { if (user[i] == comp[c]) { credit += 1; i = SIZE; c += 1; for (int i = 0; i < SIZE; ++i) { if (user[i] == comp[c]) { credit += 1; i = SIZE; c += 1; } } } } } } } } } } cout << credit << endl; return credit; }

Aucun commentaire:

Enregistrer un commentaire