C++

int to string, int to char*

쪼꼬두유 2016. 12. 2. 15:57

to_string이 c++ 11 표준이라서 NDK가 예전버전이면 빌드가 되지 않음

itoa는 c++ 비표준임 gcc에서 안돌아갈수 있음(android, ios에서 빌드가 안될수 있다는 얘기)

이왕이면 표준을 써보자 


http://stackoverflow.com/questions/8770408/convert-int-to-char-in-standard-c-without-itoa


sprintf(str, "%d", a)
str = malloc(16);
snprintf(str, 16, "%d", a);