getting weird error for while loop

I'm trying to make this program to take information from a file and save it as a string but every time it gets to the while loop, it crashes. It'll work if I only output the data so I don't know why it's not working correctly.

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
snacksJustString getQuant (int I)
{
	int Z=I-1;
	int stuff=0;
	int six=6;
	int zero=0;
	snacksJustString mabob[4];
	string stringy[23];
	string stringy2;
	snacksJustString thing;
	fstream doneDone("DrinkMachine.txt");
	while (doneDone >> stringy[stuff])
	{
		stuff++;
	}
	for (zero<5;zero++; stuff>=6)
	{
		if (stringy[six+1]=="beer" || stringy[six+1]=="soda")
		{
			stringy[six] + stringy[six+1] = mabob[zero].name;
			stringy[six+2] = mabob[zero].price;
			stringy[six+3] = mabob[zero].quant;
			six=six+4;
		}
		else
		{
			stringy[six] = mabob[zero].name;
			stringy[six+1] = mabob[zero].price;
			stringy[six+2] = mabob[zero].quant;
			six=six+3;
		}
	}
	return mabob[Z];
}
for (zero<5;zero++; stuff>=6)
You might want to review on the syntax for for-loops.
http://www.cplusplus.com/doc/tutorial/control/
http://en.cppreference.com/w/cpp/language/for
Topic archived. No new replies allowed.