0

ファイルから配列に読み込もうとする前にコードが実行され、最初に別のファイルで個別に作業していました。何がうまくいかなかったのかわかりませんが、今はデバッグできません。誰か助けてください。

#include "Questions.h"

using namespace std;

int main ()
{
    const int MAXITEMS = 15;
ifstream QuestionFile;
char a;
int count = 0;

    string question[MAXITEMS];
    string answers[10];




    int userInput = 0;
    int tries = 0;


    bool isGameOver = false;

    cout << "select 1 to start game" << endl;  gives option to start and quit game
    cout << "select 2 to quit game" << endl;
    cin >> userInput;

    if (userInput == 2)
    { 
    isGameOver = true;  to close game
        return 0;   
    };
     error message if 1 or 2 is not input
    do
    {
        if (userInput!=1 && userInput!=2)
        {
            cout << " Your input is not valid! please try again:" << endl;  error message    
            cout << "select 1 to start game" << endl;  
            cout << "select 2 to quit game" << endl;
            cin >> userInput;

            if (userInput == 2)
    {
        isGameOver = true;
        return 0;   
    };

            while (!(cin >> userInput))  error message
            {
                cin.clear();  clear the error flags
                cin.ignore(INT_MAX, '\n');  discard the row

                cout << "Your input is not valid! please try again: ";

                cout << "select 1 to start game" << endl;  
                cout << "select 2 to quit game" << endl;
            }
            cout << userInput << endl;


        }
         reprisent all characters as number to stop while problem
         when game starts gives option to select question and shows all questions
        if(userInput == 1)
        {
            QuestionFile.open ("Questions2.txt.txt"); opening this file


  if(!QuestionFile)  file testing
      cout<< " error opening file" << endl;
     // system("pause");
      //return-1;
 // };

  while(QuestionFile)       while read is working display from file into array
  {

    cout << count << " " << question << endl; for display

    QuestionFile >> question[count];     read into array

     count++;

  }

  for (int i = 0; i < count ; ++i)    displaying out the array
  {cout << " array" << i << " is ::";
  cout << question[i]<< endl;
  }

  cout << question[0]; reads in data


  QuestionFile.close();

  system ("pause");
4

1 に答える 1

0

メインを閉じますか?中括弧がありません

"}"

于 2013-04-28T17:25:21.663 に答える