C ++ LNK2019 unresolved external stdlib symbol

I have a program that requires atol () in one of its functions. So I included stdlib.h, but it doesn't seem to see it.

EDIT: I know I am using it, I have to include stdlib.h. I did it, but I am still getting this error. Function:

void
intstr( char *t )
{
    long int atol( char * );
    long x;
    int i;
    x=atol(t);

    for(i=0;i<nilit;i++){
        if(x == ilit[i]){
        lsymb =symbol[nsymb++] = 250+i;
        return;}
    }
    if( 50 <= nilit){ 
        puts("** too many int literals**");
        exit(1);
    }
    ilit[nilit++] = x;
    lsymb = symbol[nsymb++] = 249 + nilit;
}

      

The error I get when I try to build

 error LNK2019: unresolved external symbol "long __cdecl atol(char *)" (?atol@@YAJPAD@Z) referenced in function "void __cdecl intstr(char *)" (?intstr@@YAXPAD@Z)
C:x\X\X\X\Debug\p8program.exe : fatal error LNK1120: 1 unresolved externals

      

+3


source to share


1 answer


You have this code:

void
intstr( char *t )
{
    long int atol( char * );

      

What is the meaning of this atol()

incorrect announcement?
To use atol()

in your code is simple #include <stdlib.h>

.



Note that the prototype for atol () is:

long atol( const char *str );

      

(The input parameter is a const pointer.)

+2


source







All Articles