While statement trouble

Hi,
I want to make it so that if the user enter in an option that isnt provided, then it will loop back to the begining to make them choose. however no matter what the user chooses (provided or not, it loops back to the beginning). The problem i am having is in function choosestat()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <cstdlib>
#include <ctime>


int statgen();
int choosestat(int st1, int st2, int st3, int st4, int st5, int st6);

int main()
{
	srand((unsigned)time(0)); 
	int st1, st2, st3, st4, st5, st6;
	int str;
	st1 = statgen();
	st2 = statgen();
	st3 = statgen();
	st4 = statgen();
	st5 = statgen();
	st6 = statgen();
	std::cout << "Your first  is " << st1 << "\n";
	std::cout << "Your second stat is " << st2 << "\n";
	std::cout << "Your third stat is " << st3 << "\n";
	std::cout << "Your fourth stat is " << st4 << "\n";
	std::cout << "Your fifth stat is " << st5 << "\n";
	std::cout << "Your sixth stat is " << st6 << "\n";
	
	std::cout << "Which of the following would you like to be STR:\n";
	str = choosestat(st1, st2, st3, st4, st5, st6);
	std::cout << "STR=" << str << "\n";

	
	
	return 0;
}
	
int statgen()
{
	// defining my variables and giving my random a seed 
	int d1, d2, d3, d4, sum;
	d1 = rand() % 6+1;
	d2 = rand() % 6+1;
	d3 = rand() % 6+1;
	d4 = rand() % 6+1;
	

	// sets the lowest number to 0 so that the stat isnt above 18
	if (d1<=d2 && d1<=d3 && d1<=d4)
		d1 = 0;
	if (d2<=d1 && d2<=d3 && d2<=d4)
		d2 = 0;
	if (d3<=d1 && d3<=d2 && d3<=d4)
		d3 = 0;
	if (d4<=d1 && d4<=d2 && d4<=d3)
		d4 = 0;
	
	//sets the sum equal to all the dice including the 0
	sum = d1+d2+d3+d4;

	return sum;	
	}
	
int choosestat(int st1, int st2, int st3, int st4, int st5, int st6)
{
	int choice;
	
	while (choice != st1 || st2 || st3 || st4 || st5 || st6)
	{
		std::cout << st1 << "\n";
		std::cout << st2 << "\n";
		std::cout << st3 << "\n";
		std::cout << st4 << "\n";
		std::cout << st5 << "\n";
		std::cout << st6 << "\n";
		std::cin >> choice;
		if (choice != st1 || st2 || st3 || st4 || st5 || st6)
			std::cout << "Please choose one of the stats provided\n";
		}
	
	
	return choice;
}
1
2
3
4
5
6
7
do
{
    std::cout << "Please choose one of the stats provided\n";
    std::cout << st1 << "\n";
    // ...
}while (choice != st1 && choice != st2 && choice != st3 && choice != st4 && choice != st5 && choice != st6);

And dump the
1
2
if(choice ...)
    std::cout...

Ok, i see what i was doing wrong. Thankyou!
Topic archived. No new replies allowed.