this question has answer here:
i want access "number" in const char* array, subtract number const char* array , save result in first const char* array.
have code working fine on linux, in windows (vs 2015 rc) doesn't work.
int = atoi(chararr1[0][6]); //if printed shows 100 -= atoi(chararr2[0][2]); //if printed shows 93 (100-7) chararr1[0][6] = std::to_string(i).c_str(); //if print conversion, shows 93 | if print chararr1[0][6] shows nothing thanks in advance answers.
chararr1[0][6] = std::to_string(i).c_str(); that lines stores pointer @ chararr1[0][6] invalid after line since pointer data held temporary std::string object.
if want use little bit longer, create object first.
std::string temp = std::to_string(i); chararr1[0][6] = temp.c_str(); then, chararr1[0][6] hold pointer valid long temp in scope.
Comments
Post a Comment