尝试编译文件时出现非常奇怪的错误

Sam*_*nna 0 c++

错误:

尝试编译时出错

链接,因为你嵌入时无法使图像更大:http://i.imgur.com/IWJyT.png

我不知道问题是什么.我从未见过之前使用过的格式,所以我发布了一个屏幕截图.

包括整个代码,因为我不知道错误是什么.我没有别的东西可以添加到这个问题,但系统认为我这样做.还有什么我可以添加?

#include <iostream>     //Basic input/output
#include <iomanip>      //Manipulators
#include <string>       //String stuff 
#include <fstream>

using namespace std;

void instruct ();       //Function declaration for printing instructionstring studname ();
void input (ifstream &infile, float& test1, float& test2, float& test3, float& test4, float& test5, float& test6, float& test7, float& test8, float& test9, float& test10, string& studentname);      //Function declaration for input
float aver (float test1, float test2, float test3, float test4, float test5, float test6, float test7, float test8, float test9, float test10);      //Function declaration for calculating average
void output (string studentname, float average);      //Function declaration for output



int main()
{
  float test1 = 0;              //Vars (test1 - test10) for test scores
  float test2 = 0;
  float test3 = 0;
  float test4 = 0;
  float test5 = 0;
  float test6 = 0;
  float test7 = 0;
  float test8 = 0;
  float test9 = 0;
  float test10 = 0;
  string studentname = "a";     //Define Var for storing students name
  float average = 0;            //Define var for storing average


  instruct();     //Function call to print instructions


  ifstream infile("grades.dat");

  input (infile, test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, studentname);     //Function call for scores

  while (!infile.eof())
    {
      average = aver (test1, test2, test3, test4, test5, test6, test7, test8, test9, test10);    //Function call for average

      output (studentname, average);     //Function call for output

      cin.ignore(1);

      input (infile, test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, studentname); //Get new input
    }     //end eof

  return 0;
}

/***************************************************/
/* Name: instruct                                  */
/* Description: Print instructions to user.        */
/* Paramerters: N/A                                */
/* Return Value: N/A                               */
/***************************************************/

void instruct()
{
  cout << "\n" << "This program will calculate the average of 10 test scores that you input. " << "\n" << "\n";
  //Prints instructions

  return;
}

/***************************************************/
/* Name: input                                     */
/* Description: Get input                          */
/* Paramerters: N/A                                */
/* Return Value: N/A                               */
/***************************************************/

void input (float& test1, float& test2, float& test3, float& test4, float& test5, float& test6, float& test7, float& test8, float& test9, float& test10, string& studentname, ifstream& infile)

{
  infile >> studentname;
  infile >> test1 >> test2 >> test3 >> test4 >> test5 >> test6 >> test7 >> test8 >> test9 >> test10;
  infile.ignore(10, '\n');

  return;
}



/***************************************************/
/* Name: aver                                      */
/* Description: Calculate Average                  */
/* Paramerters: N/A                                */
/* Return Value: aver                              */
/***************************************************/


float aver (float test1, float test2, float test3, float test4, float test5, float test6, float test7, float test8, float test9, float test10)

{
  float aver = 0;
  aver = test1 + test2 + test3 + test4 + test5 + test6 + test7 + test8 + test9 + test10;
  aver = aver / 10;
  return aver;
}


/***************************************************/
/* Name: output                                    */
/* Description: Calculate Average                  */
/* Paramerters: N/A                                */
/* Return Value: aver                              */
/***************************************************/

void output (string studentname, float average)      //Function declaration for output
{ 

  cout << studentname;

  cout << average;

  return;
}
Run Code Online (Sandbox Code Playgroud)

正在读取的文件:

Number One
99 99 99 99 99 99 99 99 99 99
John Doe
90 99 98 89 87 90.2 87 99 89.3 91
Clark Bar
67 77 65 65.5 66 72 78 62 61 66
Scooby Doo
78 80 77 78 73 74 75 75 76.2 69
Santa Clause
89 92.5 94 95 91 89 88 90 92 91
Jessie James
45 54 55 56 66 61 65.6 67 43 54
Clara Barton
87 88 76 75.7 80 88 83 84 85 81.2
Alex Mack
55 65 66.5 67 76 77.7 66 67.8 71 70
Ann Apolis
87 88 88 88 88 85.4 81 82 89 81
Stewart Mouse
90 92 93 94 95 96 97 97.7 98 99
Sue Sloan
88.5 67.7 88.8 99.9 90.9 89 87 78 89 88
Luke Skywalker
76.7 77.8 88.8 76.7 77 88 87 86 85 80.9
Harry Potter
80 83 84 85 86 79.4 78.5 81 80 82
Mary Poppins
100 100 100 100 100 100 100 100 100 100
Last One
33 44 55 66 77 88 99 22 11 91

DaV*_*DaV 6

输入函数的参数列表不匹配.您已更改顶部版本和底部之间的顺序.

底部应该是:

void input ( ifstream& infile, float& test1, float& test2, float& test3, float& test4, float& test5, float& test6, float& test7, float& test8, float& test9, float& test10, string& studentname)

  • 通常情况下,我同意,但他已经做好了实际做功课的尝试,所以只需要一小段帮助就可以了. (3认同)
  • 鉴于这是家庭作业,我认为给OP答案是不合适的.当我们这样做时,我们最终会为他们做功课,这对他们的学习没有帮助. (2认同)