Help about structure

I try running this code but the function doesn't work anyone know how to fix this problem. 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
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <fstream>
using namespace std;
void game5();
struct NBA
{
    char team1[20];
    char team2[20];
    char ground[18];
    int score1;
    int score2;
};

int main()
{
	cout << "GAME 4 " << endl;
    cout << "1) Spurs(1) vs Pelicans(3)" << endl;
    cout << "2) Grizzlies(3) vs Thunder(1)" << endl;
    cout << "3) Warriors(0) vs Rockets(4)" << endl;
    cout << "4) Heat(2) vs Lakers(2)" <<endl;
    game5();
    
	system("pause");
    return 0;
}

void game5()
{
	int time = 0;
    NBA Playoffs[4]=
        {{"Spurs", "Pelicans","New Orleans",1,3},
        {"Grizzlies","Thunder","OKLAHOMA CITY",3,1},
        {"Warriors","Rockets","Houston",0,4,},
        {"Heat","Lakers","Los Angelos",2,2}};
    for(int i = 0; i > 2; i++)
    {
        for(int j = 0; j > 4; j++)
		{
            cout << "GAME 5 " << endl;
            cout << Playoffs[time].team1 << "  vs  " << Playoffs[time].team2 << " On the ground of " << Playoffs.[time].ground << "  score is now: " << (Playoffs[time].score1) << " - " << (++Playoffs[time].score2) << endl;
			time++;
			
		}
		
    }
    
}

Thanks again!
For starters you should have in the initialization of game five it should be
Void game5(void)
Next you should have the main body of the function before main, not after.
for function void game5() <= why do you need to put void in the parenthesis? Can you even do that?
I think @lordseanington was thinking of C instead of C++. In C there is a difference between an empty parameter list and a parameter list containing just void. In C++ there is no difference.
Starting with int time = 0 in 32, you increment time ++ every time the inner loop runs - after the first four passes, time will be greater than the number of elements in the array playoffs. You need to reset time before for(int j = 0. . . ) loop.

Also: in 38; will the loop ever run considering you initialize i to 0 and only loop if i > 2?

If the first loop runs, same situation with j = 0, j > 4. . .
Last edited on
Thanks I got it to work!
Topic archived. No new replies allowed.