# Error in compiling .cpp file

**URL:** <https://community.unix.com/t/error-in-compiling-cpp-file/353525>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [June 22, 2015, 3:47pm UTC](https://community.unix.com/t/error-in-compiling-cpp-file/353525 "2015-06-22T15:47:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bstephens](https://community.unix.com/letter_avatar/bstephens/32/6_449c533f586939b6e5f246632a46421f.png) [@bstephens](https://community.unix.com/u/bstephens)\
**Post date:** [June 22, 2015, 3:47pm UTC](https://community.unix.com/t/error-in-compiling-cpp-file/353525/1 "2015-06-22T15:47:35Z")

</div>

I get this error,

```nohighlight
defaults.cpp: In member function �int Defaults::GetIntDefault(const std::string&)�:
defaults.cpp:68: error: �atoi� was not declared in this scope
defaults.cpp: In member function �real_t Defaults::GetRealDefault(const std::string&)�:
defaults.cpp:76: error: �atof� was not declared in this scope
defaults.cpp: At global scope:
defaults.cpp:8: warning: �rcsid� defined but not used
make: *** [defaults.o] Error 1

```

when attempting to compile this code:

```nohighlight
int
Defaults::GetIntDefault( const string& defaultName ) throw ( DfltsErr )
{
    int val;
    val = atoi( GetStringDefault( defaultName ).c_str() );
    return val;
}

real_t
Defaults::GetRealDefault( const string& defaultName ) throw ( DfltsErr )
{
    real_t val;
    val = atof( GetStringDefault( defaultName).c_str() );
    return val;
}

```

The file has the following headers (I don't know if they are relevant to this problem):

```nohighlight
#include <ctype.h>
#include <fstream>
#include <sstream>
#include <cstring>
#include "msgdlg.h"
#include "defaults.h"

```

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/6_449c533f586939b6e5f246632a46421f.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [June 22, 2015, 4:39pm UTC](https://community.unix.com/t/error-in-compiling-cpp-file/353525/2 "2015-06-22T16:39:30Z")

</div>

You need cstdlib - the header where those functions are defined.
