Problem with program

Okay so i am stuck in this particular point in my program.So the program goes as follows:A menu of products shows up(the fuction metProPin(t,&pr[25]) makes it show up by getting the menu of products from a text file) and the user inputs a product code of the product that they want.If they input a right code it asks them for the quantity,if they input a wrong code it shows the list again and the program stops when they input 0.After they have inputed the number of products that they want the program is supposed to show the product number,the product name,the price and the quantity of the product.
The problem is that:1)It only keeps the last input of the product code i give it(so in the file it just shows a bunch of 0s)
2)The rest of the information like the price and the product description is just literally garbage

Some clarifications:
Proion pr[25]->array that is supposed to keep the product info.
kodProion->Product code
periPro[21]->Product name
timiPro->Product price
posothta->Quantity
and N is defined as 5.

Any help is appreciated,thanks.

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
  int menuProionta(Proion pinPro[], int n)
{
	Proion pr[25];
	int kodProion,i=0,a,p,posothta;
	char periPro[21];
	float timiPro;
	FILE *outfile;



ifstream t("text.txt");
	if(t.is_open())
	{
	
 	cout << "Give product code(Give 0 to stop)" << endl;
 	
	while(kodProion != 0)
	{
		cin >> kodProion;
	if(kodProion == 100 or kodProion == 200 or  kodProion == 300 or kodProion == 400 or kodProion==500 )
	{
	
	periPro[i]=kodProion;
	cout << "Give product quantity : " << endl;
	cin >> posothta;
	metProPin(t,&pr[25]);

	cout << "Give product code(Give 0 to stop)" << endl;
	}
	else if(kodProion != 100 or kodProion != 200 or  kodProion != 300 or kodProion != 400 or kodProion != 500)
	{
	 	cout << "Lathos " << endl;	 
	
	}	
}
cout << "ok" << endl;

}
t.close();



ofstream t1("text1.txt");
	if(t1.is_open())
	{
		
		for(i=0;i<N;i++)
		{
			t1 << kodProion  << periPro << timiPro << posothta << endl;
		}
	
	}
	t1.close();
}

Line 26 is wrong. Whatever you try to pass to metProPin(...) &pr[25] is guaranteed to be out of bounds.

The if on line 30 does not make sense. Line 26 already does is correctly.

For the input I would think a loop is missing. You only set the very first element and that's it.
Topic archived. No new replies allowed.