已调用函数时未解析的外部?

时间:2015-03-09 01:29:25

标签: c++

我有这个代码,但我一直收到intiboard的未解决的外部错误?有没有人知道为什么会这样?我认为我这样做是正确的,因为我有一个函数原型,并在main函数中调用它并在代码的末尾定义它。并参考了所有参数。另外,我没有在程序中包含其他函数的其他定义。如果我在main中注释掉initboard,代码编译得很好。 这是我得到的错误:  错误LNK2019:未解析的外部符号“void __cdecl initboard(int * const,int)”(?initboard @@ YAXQAHH @ Z)在函数_main中引用

致命错误LNK1120:1个未解析的外部

   #include <iostream>
   #include <cstdlib>
   #include <algorithm>
   using namespace std;

   const int size1=80;
   const int size2=10;
   const int size3=20;

   void initboard(int keno[], int size1);//initialize the keno board
   void twentnum(int keno[], int size3,int size1);//twenty randomly selected numbers
   void matches(int keno[],int guess[],int guess1[],int& numofmatches,int size1,int size2);
   void dispkeno(int keno[],int guess1[],int size1);//displays keno board
   void dispmess(int guess[], int numofmatches,int size2);

   int main()
   {
       int keno[size1];//keno board array
       int guess[size2];//guess array
       int guess1[size3];//first guess array
       int numofmatches;//number of matches

      //This code represents a game keno that chooses twenty random numbers 
    //from 1-80 and asks the user for 10 numbers from 1-80. The code then 
    //finds the matches between the users array and the randomly selected 
    //number array.

       initboard(keno,size1);
       twentnum(keno,size3,size1);
       matches(keno,guess,guess1,numofmatches,size1,size2);
       dispkeno(keno,guess1,size1);
       dispmess(guess,numofmatches,size2);

       return 0;
   }

   void intiboard(int keno[], int size1)
   {
    int i;
       for(i=1;i<size1+1;i++)
       {
        keno[i]=0;
       }
   }

1 个答案:

答案 0 :(得分:2)

你拼错了:) intiboard在函数定义中应该是initboard

相关问题