need help using <fstream> as a function

i've made different functions and my text file does have words in it but nothing seems to print out. could someone check and see?

1
2
3
4
5
6
7
8
9
10
11
void display_score_text(ifstream& in_s, char x ) 
{
  	in_s.open("blackjack_score.txt");
	  in_s.get(x);
   	while (! in_s.eof())
	{
	      cout << x;
	      in_s.get(x);
    in_s.close();
	}
}	


its supposed to print out
your_Nalme: wins # / loss #
Last edited on
my program runs and compiles but i can't seem print the words on the terminal. i was wondering if my function is written correctly
You close the file after printing the first character.
thank you, i've closed the loop in main
The parameters are redundant. They can be local var of display_score_text.

Also, it can be simplified as one while loop instead of many get and eof check:
1
2
while (in_s.get(x))
    cout << x;
Topic archived. No new replies allowed.