C++ LNK2019 unresolved external symbol stdlib

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'm aware to use it, I should include stdlib.h. I did that but I'm still getting this error. The 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 *)" ([email protected]@[email protected]) referenced in function "void __cdecl intstr(char *)" ([email protected]@[email protected]) C:x\X\X\X\Debug\p8program.exe : fatal error LNK1120: 1 unresolved externals

--------------Solutions-------------

You have this code:

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

What's the point of this atol() wrong declaration?
To use atol() in your code, just #include <stdlib.h>.

Note that the prototype of atol() is:

long atol( const char *str );

(The input parameter is a const pointer.)

Category:c# Time:2018-11-07 Views:1

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.435 (s). 13 q(s)