0
Picture of the out put C++起動時にテキストファイルを開くコンソールゲームに取り組んでいます。プレイヤーがルールを読んだ後、プレイヤーがいずれかのキーを押して再生すると、テキストファイルを閉じることが考えられます。次に、プレーヤーは、新しい画面上で何人のプレーヤーを入力することができる。私はテキストファイルを閉じることができないので、プレイヤーは新しいスクリーン上のプレーヤーの数を入力することができます。一番下のテキストファイルに出力します。私は間違って何をしていますか?私が理解しているものから コードC++でテキストファイルを閉じて新しいコンソールウィンドウを開く
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inputFile;
ifstream f("Text.txt");//associates the text file
cout << "Liar's Dice Copy" << endl;
if (f.is_open())//if true then allow open stream object.
cout << f.rdbuf();//Get/set stream buffer
cout << "Press any key to play" << endl;
inputFile.close(); // should close text file
getchar(); // gets key input
int numplayers;// declares numplayers
cout << "Enter Number of Players:" << endl; //print on screen
cin >> numplayers;// outputs number of players
}
*** inputFile.close(); //テキストファイルを閉じる必要があります***コンソールに表示されている内容には影響しません。 – drescherjm
***プレイヤーは新しい画面に何人のプレーヤーを入れることができるのですか?標準の 'C++ 'はこれを行う方法がありませんが、winapiのコンソール機能はそうするべきです。 https://stackoverflow.com/questions/6486289/how-can-i-clear-console – drescherjm
***私は間違っていますか?***私はあなたが主に、コンソールがどのように標準の 'C++' 。 – drescherjm