files

Hey, so I have to read in a file and I think I'm doing everything right but when i go to debug it only a black screen appears and when i exit the black screen at the bottom under outputs it says cannot find or open pdb file. Can anyone find what i'm doing wrong? I have both of the files open until the resource files. Here's my code:

#include<iostream>
#include <string>
#include <fstream>
using namespace std;

struct dataStruct {
string playerId,
lastName,
firstName,
division,
team;
double plateAppearances,
atBats,
singles,
doubles,
triples,
homeRuns,
sackFlys,
walks,
hitByPitch,
battingAvg,
onBasePercentage,
slugginPercentage,
hits,
sacrifices,
sacrificeFlys;
};

int main(){

string playerId = "",
lastName = "",
firstName = "",
division = "",
team = "";
double plateAppearances = 0,
atBats = 0,
singles = 0,
doubles = 0,
triples = 0,
homeRuns = 0,
sackFlys = 0,
walks = 0,
hitByPitch = 0,
battingAvg = 0,
onBasePercentage = 0,
slugginPercentage = 0;

{
dataStruct playerStats[500];
dataStruct newPlayerStats[500];
int counter = 0;
int otherCounter = 0;
ifstream inFile;
ifstream masterData("Master_Data.csv", ios::in);
ifstream newStats("2014_League_Stats.csv");

if (masterData.is_open())
{
while (!masterData.eof())
{
getline(masterData, playerStats[counter].playerId, ',');
getline(masterData, playerStats[counter].firstName, ',');
getline(masterData, playerStats[counter].lastName, ',');
getline(masterData, playerStats[counter].division, ',');
getline(masterData, playerStats[counter].team, ',');
masterData >> playerStats[counter].plateAppearances;
masterData.ignore(',');
masterData >> playerStats[counter].atBats;
masterData.ignore(',');
masterData >> playerStats[counter].singles;
masterData.ignore(',');
masterData >> playerStats[counter].doubles;
masterData.ignore(',');
masterData >> playerStats[counter].triples;
masterData.ignore(',');
masterData >> playerStats[counter].homeRuns;
masterData.ignore(',');
masterData >> playerStats[counter].sackFlys;
masterData.ignore(',');
masterData >> playerStats[counter].walks;
masterData.ignore(',');
masterData >> playerStats[counter].hitByPitch;
masterData.ignore(',');
masterData >> playerStats[counter].battingAvg;
masterData.ignore(',');
masterData >> playerStats[counter].onBasePercentage;
masterData.ignore(',');
masterData >> playerStats[counter].slugginPercentage;
masterData.ignore(',');
}
}
else
{
cout << "Error Reading File" << endl;
}
if (newStats.is_open())
{
while (!newStats.eof())
{
getline(newStats, newPlayerStats[otherCounter].playerId, ',');
getline(newStats, newPlayerStats[otherCounter].firstName, ',');
getline(newStats, newPlayerStats[otherCounter].lastName, ',');
getline(newStats, newPlayerStats[otherCounter].division, ',');
getline(newStats, newPlayerStats[otherCounter].team, ',');
newStats >> newPlayerStats[otherCounter].plateAppearances;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].atBats;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].singles;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].doubles;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].triples;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].homeRuns;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].sackFlys;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].walks;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].hitByPitch;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].battingAvg;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].onBasePercentage;
newStats.ignore(',');
newStats >> newPlayerStats[otherCounter].slugginPercentage;
newStats.ignore(',');
}
}
else
{
cout << "Error Reading File" << endl;
}

if (inFile.is_open())
{
while (!masterData.eof())
{
playerStats[counter].atBats = (playerStats[counter].plateAppearances + newPlayerStats[otherCounter].plateAppearances) -
((playerStats[counter].walks + newPlayerStats[otherCounter].walks) +
(playerStats[counter].hitByPitch + newPlayerStats[otherCounter].hitByPitch) +
(playerStats[counter].sacrifices + newPlayerStats[otherCounter].sacrifices));
playerStats[counter].hits = ((playerStats[counter].singles + newPlayerStats[otherCounter].singles) +
(playerStats[counter].doubles + newPlayerStats[counter].doubles) +
(playerStats[counter].triples + newPlayerStats[otherCounter].triples) +
(playerStats[counter].homeRuns + newPlayerStats[otherCounter].homeRuns));
playerStats[counter].battingAvg = ((playerStats[counter].hits) / ((playerStats[counter].atBats)));
playerStats[counter].onBasePercentage = ((playerStats[counter].hits) +
(playerStats[counter].hitByPitch) + newPlayerStats[otherCounter].hitByPitch) +
(playerStats[counter].walks + newPlayerStats[otherCounter].walks) /
((playerStats[counter].atBats) + (playerStats[counter].walks + newPlayerStats[otherCounter].walks) +
(playerStats[counter].hitByPitch) + newPlayerStats[otherCounter].hitByPitch) +
(playerStats[counter].sacrificeFlys);
playerStats[counter].slugginPercentage = (playerStats[counter].hits / playerStats[counter].atBats);


masterData.close();
newStats.close();
}
}
}
}
Topic archived. No new replies allowed.