mardi 3 décembre 2019

hot to convert std::__cxx11::string to std::string

so i just want to convert int in digits and store it in array

for eg

int n=456;

std::string nstr = std::to_string(n);

std::cout << nstr[0];

now i just want the length of nstr...

whenever i am using std::strlen(nstr);

its giving an error

**error: cannot convert 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'**

please tell me how to convert std::__cxx11::string to std::string

or is there any other way to calculate length of nstr

Aucun commentaire:

Enregistrer un commentaire