My script stops working midway

Hi guys I wrote a script that is suppose to do the following functions


1-Asks the user to enter the number of teams he wants in a tournament, he also writes in the names of the teams.

2-Sets up a struct called "Folder" to combine the teams and make sure they all have records(Games, wins, losses and points) all intial records are set to 0

e.g
If you enter 2 teams named West and East this is what you save:

West 0 0 0 0 0
East 0 0 0 0 0


3-Finally the function stores the data in a text file the file should read

Team GP-W-L-OT-PTS
West 0 0 0 0 0
East 0 0 0 0 0


Now I did the "combine" script seperatly and made sure it worked, then I did the script for --storing it to a file-- by itself and it worked.

When I combined the two they stop after the first script

here is my code

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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <string>
#include <stdio.h>
#include <string.h>

#include <limits>






using namespace std;

       
struct Team {                         // data structure that is a Teams info
       string name[10];
      int record[5];
      int GFGA[5];
       };
struct Folder{                       // Data structure that collects Teams
       Team club[10];
       };
Folder Combiner();                        
void Writer(Folder J, int k);
 
int main() {
    int n;
     Folder N;
ofstream outputFile;
Folder TeamSet;
 string outputFilename;
 
 
 N=Combiner ();
 
 n=sizeof(TeamSet.club) / sizeof(int);
 
 cout << "Output filename: ";           // stops right here- after it asks for the  output file name 
getline (cin, outputFilename);                 
outputFile.open(outputFilename.c_str(),ios::out );

outputFile <<"Team "<< "GP-"<<"W-"<<"L-"<<"OT-"<<"PTS"<< endl;  // here is just formating

for (int p=0; p<n; p++) {                                  // loop that writes in the Folder data
    for (int j=0; j<n; j++){
outputFile <<N.club[p].name[0]<<"-"<<N.club[j].record[0]<<"-"<<N.club[j].record[1]<<"-"<<N.club[j].record[2]<<"-"<<N.club[j].record[3];
outputFile<<"-"<<N.club[j].record[4]<<endl;

 
}
}

  system("pause");

  return 0;

}






//////////////////////////Below program combines teams into a folder( it works)
Folder Combiner() {
       Folder League;
       int n;
cout<<" enter number of teams" << endl;
cin>>n;
cout<<"enter names"<<endl;



for (int j=0; j<n; j++) {
cin>> League.club[j].name[j];
}

for (int j=0; j<n; j++) {
    for (int p=0; p<5; p++){
    League.club[j].record[p]= 0;
}
}


for (int j=0; j<n; j++) {
    
    cout<<League.club[j].name[j]<<" ";
    for (int p=0; p<5; p++){
    cout<<League.club[j].record[p]<<" ";
}
cout<<endl;
}

return League;
}
Last edited on
Topic archived. No new replies allowed.