문제

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);
도움이 되었습니까?

해결책 2

Does this work?

#include <string>
std::string buf = std::to_string(i);
key1.append(buf);
key2.append(buf);
key3.append(buf);

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top