Reputation: 6058
This may be a vaugue question but im getting this error
Simulator.cpp: In member function `void Simulator::generatePassengers()':
Simulator.cpp:60: error: `itoa' undeclared (first use this function)
This is the code im having an issue with
itoa(i,buf,10);
What can i use to fix this issue because on one compiler i get this issue on another i dont. So im stumped here has to work on both.
char buf[3];
if(i<10)
{
key1.append("0");
key2.append("0");
key3.append("0");
}
itoa(i,buf,10);
key1.append(buf);
key2.append(buf);
key3.append(buf);
Upvotes: 1
Views: 4574
Reputation: 6058
Does this work?
#include <string>
std::string buf = std::to_string(i);
key1.append(buf);
key2.append(buf);
key3.append(buf);
Upvotes: 3
Reputation: 182829
Your platform doesn't have itoa. It's not specified by any standard. You can use any replacement you like, including printf
or just writing your own.
Upvotes: 3