HELP! opening files

Hey, so I have to write code to open these files and do further stuff to them but I can't even get the main file to open/read in. I have the files open under resource files and my code is below, but once I run it, it opens a blank black screen and then just closes right away. Once it closes the output box at the bottom says cannot find or open the PDB file. Is there something wrong with my code or am i supposed to do something else with the files? HELP!!



#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()
{
const string nameOfFile = "Master_Data.csv";
dataStruct inData[1000];
int count = 0;

ifstream inFile;
inFile.open("Master_Data.csv", ios::in);

if (inFile.is_open() == true){
while (!inFile.eof()){
getline(inFile, inData[count].playerId, '#');
getline(inFile, inData[count].lastName, '#');
getline(inFile, inData[count].firstName, '#');
getline(inFile, inData[count].division, '#');
getline(inFile, inData[count].team, '#');

inFile >> inData[count].plateAppearances;
inFile.ignore();
inFile >> inData[count].atBats;
inFile.ignore();
inFile >> inData[count].singles;
inFile.ignore();
inFile >> inData[count].doubles;
inFile.ignore();
inFile >> inData[count].triples;
inFile.ignore();
inFile >> inData[count].homeRuns;
inFile.ignore();
inFile >> inData[count].sackFlys;
inFile.ignore();
inFile >> inData[count].walks;
inFile.ignore();
inFile >> inData[count].hitByPitch;
inFile.ignore();
inFile >> inData[count].battingAvg;
inFile.ignore();
inFile >> inData[count].onBasePercentage;
inFile.ignore();
inFile >> inData[count].slugginPercentage;
inFile.ignore();
}
}
else
cout << nameOfFile << "file could not be opened" << endl;

}
Topic archived. No new replies allowed.