vs2019无法解析外部符号问题如何解决(错误代码:LNK2019)

问题遇到的现象和发生背景

使用void定义函数后在main函数中使用,报错(错误代码:LNK2019和LNK1120)
错误 LNK2019 无法解析的外部符号 _main,函数 "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 中引用了该符号 the fourth chapter E:\visual studio\c++\the fourth chapter\the fourth chapter\MSVCRTD.lib(exe_main.obj)

问题相关代码,请勿粘贴截图
void act1(int(x), int(y)) {
    y = x;
    printf("%d", y);
}
void act2(int(x), int(y)) {
    y = 2 * x - 1;
    printf("%d", y);
}
void act3(int(x), int(y)) {
    y = 3 * x - 11;
    printf("%d", y);
}
int mian() {
    int x, y = 0;
    scanf_s("%d", &x);
    putchar('\n');
    switch (x) {
    case 0:act1(x, y); break;
    case 1:
    case 9:act2(x, y);  break;
    case 10:act3(x, y);  break;
    }
    printf("answer is %d", y);
    return 0;
}

运行结果及报错内容

程序无法执行
错误 LNK2019 无法解析的外部符号 _main,函数 "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 中引用了该符号 the fourth chapter E:\visual studio\c++\the fourth chapter\the fourth chapter\MSVCRTD.lib(exe_main.obj)

img

我的解答思路和尝试过的方法

尝试不使用void定义的函数执行,任然报错

int mian() {
    int x, y = 0;
    scanf_s("%d", &x);
    putchar('\n');
    switch (x) {
    case 0:y = x; break;
    case 1:
    case 9: y = 2 * x - 1;  break;
    case 10:y = 3 * x - 11; break;
    }
    printf("answer is %d", y);
    return 0;
}

报错内容相同

我想要达到的结果

解决问题

img


主函数是main()函数,而不是mian函数。
这个细节虽然很小,但是很关键,main()毕竟为主函数。

解决方案:mian改为main

以上仅供参考,如有任何疑问,可以评论回复,看到即回。
希望对题主有所帮助!可以的话,帮忙点个采纳!

是main函数,不是mian函数