All pastes #925723 Raw Edit

Untitled

public cpp v1 · immutable
·published 2008-03-03 06:20 UTC
rendered paste body
cout << "What file contains the game data?" << endl;cin >> fileName;fstream file;// open the filefile.open(fileName);// the rest of the code is just the general implementation of the blackjack game, nothing important to the file i/o// if the player wins, his bank is changed in accordance to his bet// playerExist[count] determines if the player has already played the game or not, if the player is new to the game, his stats // are written to the end of the file.  Otherwise, the program is supposed to find the player name (which it does) and change // the number of chips next to it (which it does not)for(int count = 0; count < numPlayers; count++){	bool playerFound = false;	if(toupper(playerExist[count]) == 'N')	{		file.seekp(0L, ios::end);		file << player[count].name;		file << " ";		file << player[count].hand.bank;		file << endl;	}	else if(toupper(playerExist[count]) == 'Y' && !playerFound)	{		char currName[50];		// loop through the file until end of file or player is found		while(!file.eof() && !playerFound)		{			// read names into a variable			file >> currName;			// test if the name is the name were looking for			if(strcmp(currName, player[count].name) == 0)			{                                // put a space between name and bank for readability				file << " ";				// write bank to the next spot in the file				file << player[count].hand.bank;                                // write an endline to file for readability				file << endl;				playerFound = true;			}                        // if the player has been found			if(playerFound)			{				file.clear();                                // reset the write point to beginning of file				file.seekg(0, ios::beg);			}		}	}}