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
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <limits>
usingnamespace 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;
}