#include "stdafx.h"
#include <iostream>
using namespace std;
long factorial(int n);
void main()
{
int m;
cout<<"请输入n值:";
cin>>m;
cout<<factorial(m)<<endl;
}
long fatorial(int n)
{
long result=0;
if(n==0)
result=1;
else
result=n*factorial(n-1);
return result;
}
The output comes out error below:
1>ClCompile:
1> All outputs are up-to-date.
1> Ex_Factorial.cpp
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>Ex_Factorial.obj : error LNK2019: unresolved external symbol "long __cdecl factorial(int)" (?factorial@@YAJH@Z) referenced in function _main
1>D:\Studio\test\Ex_Factorial\Ex_Factorial\Debug\Ex_Factorial.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:06.32
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have try every means whatever I could find, but I can't yet correct the error. Please help me!