LNK2019: unresolved external symbol "void __cdel referencd in function _main
//main.cpp
#include <iostream>
using namespace std;
void GetStudentInfo();
int main()
{
GetStudentInfo();
return 0;
}
//stdinfo.cpp
//stud是结构体
void GetStudentInfo()
{
int i=1;
ifstream in("stdinfo.txt");
if(!in)
{
cout<<"ERROR_OPEN_STDINFO"<<endl;
exit(0);
}
string str;
while(getline(in,str))
{
stud[i].stdID = str.substr(0,10);
stud[i].classNum = atoi(str.substr(10,1).c_str());
stud[i].name = str.substr(11,str.length()-11);
stud[i].subID = atoi(str.substr(6,4).c_str());
i++;
}
}
然后编译的时候会出现如下错误:
LNK2019: unresolved external symbol "void __cdecl GetStudentInfo(void)" (?GetStudentInfo@@YAXXZ) referenced in function _main
如果把GetStudentInfo()里面的内容放在主函数里面就不会出现这个问题,该怎么解决啊?