C++ (c+;+;)无法使void函数工作,main.cpp中的几行也有问题

C++ (c+;+;)无法使void函数工作,main.cpp中的几行也有问题,c++,C++,我在下面输入的代码中遇到了一些问题。void函数看起来不错,但不起作用。我不确定我做错了什么,所以非常感谢你的帮助。另外,我不知道如何使用if语句从两个玩家的内嵌中调用问题,如下所示。请,我必须在12月3日晚上11点交上来,谢谢你的帮助。我已经做了5个小时了 如果此处的语句用于向玩家1显示奇数个问题,向玩家2显示偶数个问题,请确保通过调用函数upDateScoreDouble为各个玩家添加正确的分数 void getHistory (playerHistory pHist[], int loop

我在下面输入的代码中遇到了一些问题。void函数看起来不错,但不起作用。我不确定我做错了什么,所以非常感谢你的帮助。另外,我不知道如何使用if语句从两个玩家的内嵌中调用问题,如下所示。请,我必须在12月3日晚上11点交上来,谢谢你的帮助。我已经做了5个小时了

如果此处的语句用于向玩家1显示奇数个问题,向玩家2显示偶数个问题,请确保通过调用函数upDateScoreDouble为各个玩家添加正确的分数

void getHistory (playerHistory pHist[], int loopy, ifstream& inQuest)
    {
        int i = 0 ;
        loopy = 22 ;
        while( i < loopy, i++)
        {
        inQuest >> pHist[i].alias1 ;
        inQuest >> pHist[i].score ;
        inQuest >> pHist[i].difficulty ;
        inQuest >> pHist[i].date ;
        }

        return ;
    }


    void bubblesort (playerHistory pHist[], int length)
    {
        bool swapped = true;
          int j = 0;
          int tmp;
          while (swapped) {
                swapped = false;
                j++;
                for (int i = 0; i < length - j; i++) {
                      if (pHist[i].score > pHist[i + 1].score) {
                            tmp = pHist[i].score;
                            pHist[i].score = pHist[i + 1].score;
                            pHist[i + 1].score = tmp;
                            swapped = true;
                      }
                }
          }
    return ;
    }

///3.3.6 create a loop to call the getQuestion function for each question
            for(int loopy=1; loopy<=numQuestions; loopy++)
                {

                ///3.3.6.2 getQuestion function call
                    getQuestion(gameQ, numQuestions, inQuest) ;
                ///3.3.6.1 if statement here to display odd number of questions to player1 and even number of questions to player2
                ///make sure to add the correct score for respective player by calling the function upDateScoreDouble
                if(loopy < numQuestions)
                {
                    inQuest >> gameQ[loopy].question;
                    cout << gameQ[loopy].question ;
                    cout << gameQ[loopy].answer ;
                    cout << gameQ[loopy].ans1 ;
                    cout << gameQ[loopy].ans2 ;
                    cout << gameQ[loopy].ans3 ;
                    cout << gameQ[loopy].ans4 ;

                }


                }   ///end of for loop of number of questions
void-getHistory(playerHistory-pHist[],int-loopy,ifstream&inquist)
{
int i=0;
loopy=22;
而(i>菲斯特[i].别名1;
审讯>>菲斯特[i].分数;
勘验>>菲斯特[i].难度;
勘验>>菲斯特[i].日期;
}
回来
}
void bubblesort(playerHistory pHist[],整数长度)
{
bool swapped=true;
int j=0;
int tmp;
while(交换){
交换=假;
j++;
对于(int i=0;ipHist[i+1].score){
tmp=pHist[i]。得分;
pHist[i]。分数=pHist[i+1]。分数;
pHist[i+1]。分数=tmp;
交换=真;
}
}
}
回来
}
///3.3.6创建一个循环,为每个问题调用getQuestion函数
对于(int-loopy=1;loopy>gameQ[loopy]),问题;

cout在
getHistory
函数中,看起来您需要一个
for
循环

因为表达式
i
计算
i
,然后丢弃结果

相反,循环的条件是
i++
,由于在第一次迭代中它是
0
,因此结果为假,循环从未发生

阅读有关逗号运算符的更多信息

你可能想要像这样的东西

for (int i = 0; i < 22; ++i) { ... }
(inti=0;i<22;++i){…}