必须定义LNK1561入口点

时间:2015-10-18 18:16:58

标签: c++

这是我的代码,它是用C ++语言编写的,我和int main(){}一样,在我的所有程序中,我仍然收到此错误消息。帮助

#include<iostream>
#include <ctime>
using namespace std;

int main(){

int fibo(int n)
{
    if (n == 0)
        return 0;
    else if (n == 1)
        return 1;
    else
        return fibo(n - 1) + fibo(n - 2);
}

void main()
{
    clock_t t;
    t = clock();
    int n, i;
    cout << "Enter the total number of elements: ";
    cin >> n;
    cout << "\nThe Fibonacci series is:\n";
    for (i = 0; i < n; i++)
    {
        cout << fibo(i) << " ";
    }
    t = clock() - t;
    cout << "\nThe time required is:";
    cout << t / CLOCKS_PER_SEC;
    getch();
}
}

1 个答案:

答案 0 :(得分:0)

删除额外的主要

#include <iostream>
#include <conio.h>
#include <time.h>

// force to use main entry point as startup
#pragma comment(linker, "/ENTRY:mainCRTStartup")

using namespace std;

int fibo(int n)
{
    if (n == 0)
        return 0;
    else if (n == 1)
        return 1;
    else
        return fibo(n - 1) + fibo(n - 2);
}

int main()
{
    clock_t t;
    t = clock();
    int n, i;
    cout << "Enter the total number of elements: ";
    cin >> n;
    cout << "\nThe Fibonacci series is:\n";
    for (i = 0; i < n; i++)
    {
        cout << fibo(i) << " ";
    }
    t = clock() - t;
    cout << "\nThe time required is:";
    cout << t / CLOCKS_PER_SEC;
    getch();
    return 0;
}

或转到项目属性而不是配置属性 - &gt;链接器 - &gt;命令行并粘贴到其他选项/ SUBSYSTEM:CONSOLE