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
|
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<fstream>
#include<cctype>
#include<string>
using namespace std;
struct NBA_Team
{
char* name;
char conference[8];
char division[10];
unsigned short wins;
unsigned short losses;
float pct;
};
const int teamnames = 0;
const int win = 1;
const int loss = 2;
const int percent = 3;
const int col = 4;
const int dteamn = 5;
void getname (const string&, NBA_Team *, NBA_Team &);
int main()
{
NBA_Team NBAT;
NBA_Team teaminfo[dteamn];
string con, divi;
char buffer[16], buffer1[16];
const string namefile = "c:/temp/namefile.txt";
const string scorefile = "c:/temp/scorefile.txt";
getname(namefile, teaminfo, NBAT);
system("PAUSE");
}
void getname (const string &f, NBA_Team *p, NBA_Team &q)
{
string con, divi;
char buffer[90], buffer1[16];
char* namez = new char[90];
ifstream fin(f);
if (!fin)
{
cerr << "Unable to open file " << f << endl;
exit(1);
}
fin >> q.conference >> con >> q.division >> divi;
for (int i = 0; i < dteamn; i++)
{
fin>>buffer;
char* pch = strchr(buffer,'\n');
while (pch==NULL)
{
strcat(buffer," ");
fin >> buffer1;
strcat(buffer,buffer1);
pch=strchr(buffer1,'\n');
}
p[i].name = new char[strlen(buffer+1)];
p[i].name = buffer;
cout << p[i].name<<" " << p[0].name<<endl;
}
cout << q.conference << " " << con << " " << q.division << " " << divi << endl;
for (int i = 0; i < dteamn; i++)
{
cout << p[i].name<<endl;
}
}
|