error C2061: syntax error : identifier 'fstream'

trying to write to my output file in a function but it shows this error
Snips of code,
1
2
3
4
5
#include <iostream>
#include <ctime>	// Needed for Random number
#include <cstdlib>	// Exit from function
#include <string>	// If statment
#include <fstream>	// need to read file 

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
void PrintScoresAndHands(int ComputerHand[], const int ComputerCardCount, int PlayerHand[], const int PlayerCardCount, char Player[15], int &WhatNow, fstream wins, int Player1win&, int Player1lose&, int &Player1tie, int &Computerwin, int &Computerlose, int &Computertie); // Print ending score for single player
void mPrintScoresAndHands(int Player2Hand[], const int Player2CardCount, int PlayerHand[], const int PlayerCardCount, char Player[15], int &WhatNow, char Player2[15]); // Print ending score for two player


int main() {
	using namespace std;
	//Random number generator, number is different each second. Super random numbers.
	// Seeds number generator with the time
	time_t qTime;				     
	time(&qTime);				// time function
	srand(qTime);				// pass time to srand

	//Declare
	fstream wins;				// Output file
	bool CardDeck[52];			// Deck of cards, 52 cards
	int ComputerCardCount = 0;	// Set card count to 0, computer
	int PlayerCardCount = 0;	// Set card count to 0, player
	int Player1CardCount = 0;	// Set card count to 0, Player 1 in two player
	int Player2CardCount = 0;	// Set card count to 0, player 2 in two player
	int ComputerHand[12];		// Computer cards, possable 12 random numbers
	int PlayerHand[12];			// Players 1 cards, possable 12 random numbers, anymore cards would bust
	int Player2Hand[12];		// Player 2 cards, possable 12 random numbers, anymore cards would bust
	char Player[15];			// Player 1's name
	char Player2[15];			// Player 2's name
	int WhatNow;				// Menu after hand weather to play again or exit
	int Choice;					// Main menu choice of single player, two player, or exit

	//Files
	wins.open("wins.dat");		//Open file, output file 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void PrintScoresAndHands(int ComputerHand[], const int ComputerCardCount, int PlayerHand[], const int PlayerCardCount,  char Player[15], int &WhatNow, fstream wins, int Player1win&, int Player1lose&, int &Player1tie, int &Computerwin, int &Computerlose, int &Computertie) {
	#include <fstream>	// need to read file
	using namespace std;																	   // cout enable
	cout << "Computer's Hand: Score = " << ScoreHand(ComputerHand, ComputerCardCount) << endl; // show computers hand and total
	PrintHand(ComputerHand, ComputerCardCount);												   //show computers cards
	cout << Player << "'s Hand: Score = " << ScoreHand(PlayerHand, PlayerCardCount) << endl;   // show players hand and total
	PrintHand(PlayerHand, PlayerCardCount);													   // show player 1 cards
	cout << endl;																			   // next line
	cout << "Do you want to play again? (Enter Number) (1) Yes or (2) Exit " << endl;		   // Ask if player wants to play again
	cin >> WhatNow;																			   // display input
	if (WhatNow == 2) 
	wins << Player << " Wins:" << Player1win << " Ties:" << Player1tie << " Lose:" << Player1lose << endl;
	wins << "Computer Wins:" << Computerwin << " Ties:" << Computertie << " Lose:" << Computerlose << endl;
		exit(1);																			   // If they enter 2 then exit program

}
Just from looking through, here's what I notice:

You #include fstream twice, once at the beginning, once in a function.

You include using namespace std; multiple times.

I don't know if those two will cause problems, but I suggest removing the multiple declarations and place using namespace std; after including files.

I haven't played with C++ in a while, but I think your delaration of fstream wins; is off, go here to figure out what's wrong:

http://cplusplus.com/doc/tutorial/files/

Could you post the entire code please? Knowing how the program is supposed to work (what each function does and where and when it does it) will help identify all the problems you have.
Topic archived. No new replies allowed.