c++ - char* to std::string -
i have character array (char* pdata) in c++, want copy data (from pdata) in std::string. code looks this:
std::string ssomedata(pdata+8);//i want copy data starting index 8 till end the problem when above statement executes string contains nothing in it. guess pdata not terminated '\0' thats why not working.
regards, jame.
if know size of pdata, can use construct-from-iterators constructor:
std::string ssomedata(pdata + 8, pdata + size_of_pdata);
Comments
Post a Comment