variable 'error' being used without being initalized?

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
#include <iostream>

using namespace std;

int addition (int x, int y)
{
	int r;
	r=x+y;
	return (r);
}

int main()
{
	int z;
	z = addition (5, 3);
	cout<<"The result is " << z;
	cout<<"\n";
	system("pause");
	int patiencetest = 500;
	int error;

	for (int error; error <= patiencetest; error++)
	{
		cout<<".\n";
	}
	int input;
	cin>>input;
	if (error >= patiencetest)
	{
		cout<<"Congratulations! You've pasted the patience test. As you've been taught, it's always good to \
			  wait to see if anything else happens before continuing on.\n";
		cin.get();
	}
	else {

		int fail;
		int stop = 1000000;
		
		for (int fail; fail <= stop; fail++)
		{
			cout<<"6  ";
		}
	}
	int fail;
	int stop = 500000;
	if (fail >= stop) {

		cout<<"Congratulations! You've passed the secondary patience test. You won't be as well ranked as you would \
			  \n have if you passed the first test. Noob!\n";
		cin.get();
	}
	}


"The variable 'error' is being used without being initialized."


The program's purpose is for the user to hit any button, and then integer error will continue to increase until a certain amount. When that certain amount hits, the message "Good job passing etc." will appear. If he presses any key before integer error reaches the target amount, approximately one million 6s will appear in the program to make it look like the program was hacked or a virus affected it.

I would love to fix it, but I can't find out why or how int error was not initialized.
1
2
3
4
5
6
int error; // Define Error, but no value?

	for (int error /* Re-define error, again it has no value */; error <= patiencetest; error++)
	{
		cout<<".\n";
	}


Those are your problems. You are not initialising Error with a value.
Fantastic. Now I just have a few problems within the code to fix (bugs that give no errors).
Topic archived. No new replies allowed.