First program, need help to open file

#include <iostream>
#include <string>
#include <fstream>
#include <cctype>
#include "main.h"

using namespace std;



int main(void)
{
ifstream playerFile;
ofstream outfile;

playerFile.open ("playerStats.txt");

bool gameOver = false; // game loop control flag
char posLocation; // user input variable for position choice
char playAgain = 'A'; // program exit control flag
char playerSymbol = 'X'; // current player symbol
char menuoption;
char nameOne;
char nameTwo;
string pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9; // board display variables

DisplayIntro(); // Display introduction screen
DisplayMenu(); //Display Menu screen*

cin >> menuoption;

menuoption = toupper(menuoption); //convert to uppercase

enum Menu {PLAY, DISPLAY, SAVE, SORT, EXIT};
if (menuoption = PLAY)
{
AskForName(nameOne, nameTwo);
AskForSymbol(playerSymbol);
}
if (menuoption = DISPLAY);
{
displayStats ();
}


if (menuoption = SAVE);
}
saveStats()
{




if (menuoption = SORT);
{
selectionsSortData();
}




if (menuoption = EXIT)

DisplayCredits(); // Display the credit screen
playerFile.close();
outfile.close();
return 0;
}
void displayStats (ofstream& outfile, (ifstream& playerFile player[index]), int listsize, char name, int wins, int loss, int ties, int total);
{
struct playerFile
{
char name;
int wins;
int loss;
int ties;
int total;

};
int index;
ifstream playerFile;
playerFile.open("playerStats.txt");
infile();
playerFile player[index];
index=0
for (index=0; index++);
{
infile >> player[index].name
>> player[index].wins
>> player[index].loss
>> player[index].ties
>> player[index].total;
}


ofstream;
cout << "__________ PLAYER STATS ___________"<< endl;
for (index=0; index < listsize; index++)

outfile << player[index].name << player[index].wins << player[index].loss << player[index].ties << player[index].total;

}

use code tag if not hard to see your code 1 by 1 .
see beside your format . got a icon <>
Last edited on
Topic archived. No new replies allowed.