Compiling simple C++ program in linux (first time)
Linux does not provide an itoa
implementation. Best way to achieve same behavior, and working with C++11, is using std::to_string
in the following way:
std::string tmp = std::to_string(1);
If you're using an older C++ version, you can use string streams:
std::stringstream tmpSS;tmpSS << 1;std::string tmp = out.str();
Edit: In provided example, you would need to also call std::string
's c_str()
method:
employee->setID( (char*) tmp.cstr() ); //Set id
Where tmp
is one of previous options.
This function is not defined in ANSI-C and is not part of C++, but is supported by some compilers.
So it seems that the problem is that your compiler dows not support the itoa function.
Not sure what is the problem (show part of you code?). itoa
is a non-standard function in C++.
If you want to convert integer to string in C++, and you can use std::to_string function in C++11.