Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Error in compiling .cpp file

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-22-2015   -   Original Discussion by bstephens
bstephens's Unix or Linux Image
bstephens bstephens is offline
Registered User
 
Join Date: Jun 2015
Last Activity: 22 June 2015, 3:49 PM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Error in compiling .cpp file

I get this error,


Code:
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:


Code:
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):


Code:
#include <ctype.h>
#include <fstream>
#include <sstream>
#include <cstring>
#include "msgdlg.h"
#include "defaults.h"

Sponsored Links
    #2  
Old Unix and Linux 06-22-2015   -   Original Discussion by bstephens
jim mcnamara's Unix or Linux Image
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 14 December 2017, 3:00 PM EST
Location: NM
Posts: 11,253
Thanks: 577
Thanked 1,122 Times in 1,034 Posts
You need cstdlib - the header where those functions are defined.

Last edited by jim mcnamara; 06-22-2015 at 05:40 PM.. Reason: I cannot type
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error with shared lIBMpi.so.1 when compiling CPP program yifangt Programming 0 03-25-2014 01:59 PM
<Apache>error when compiling CPP modules ashabb Web Programming 0 05-18-2012 06:15 AM
If file = .cpp then print? Irish_Cereal Shell Programming and Scripting 5 10-14-2008 11:20 PM
Compiling multiple cpp files (abstract factory pattern) SaTYR Programming 4 06-13-2008 05:55 AM



All times are GMT -4. The time now is 06:51 PM.