缺少main()会阻止链接时的可执行文件创建

Jos*_*Lee -1 c linker kernighan-and-ritchie

我在Windows上使用Microsoft Visual C++.我编译好没有任何错误.但是,当我尝试执行它时,我遇到了两个错误.我读了调试错误,我无法理解它们.我在C编程方面有点新手.

此代码来自第61页的Kernighan和Ritchie的教科书:

#include <ctype.h>

/* atoi: convert s to integer; version 2 */
int atoi(char s[])
{
    int i, n, sign;

    for (i=0; isspace(s[i]); i++) /* skip white space */
        ;
    sign = (s[i] == '-') ? -1: 1;
    if (s[i] == '+' || s[i] == '-') /* skip sign */
        i++;
    for (n=0; isdigit(s[i]); i++)
        n = 10 * n + (s[i] - '0');
    return sign*n;
}
Run Code Online (Sandbox Code Playgroud)

错误:

--------------------Configuration: 3.5 - Win32 Debug--------------------
Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/3.5.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. 3.5.exe - 2 error(s), 0 warning(s) 
Run Code Online (Sandbox Code Playgroud)

Dav*_*rtz 5

那不是一个完整的计划.这只是一个功能.如果不编写一些代码来调用它,就无法执行它.