I am using Microsoft Visual C++ on Windows. I compiled it fine without any errors. However, when I tried to execute it, I got two errors. I read the debugging errors, and I could not understand them. I am somewhat a newbie in C programming.
This code is from Kernighan and Ritchie's textbook on page 61:
#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;
}
The error:
--------------------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)