c++ - I am having an issue storing a character in a pointer to a structure. -


string* substr(string* str, int start, int end) {    string* substr = new string;    for(int = start; < end; i++)    {       substr = str->text[i];    }        return substr; } 

//the problem in substr method. substr supposed store part of string separated delimiter.

since substr pointer object of string struct, should point object's array of chars. this:

string* substr(string* str, int start, int end) {     string* substr = new string;     for(int = start; < end; i++)     {         substr->text[i] = str->text[i];    // char = char     }         return substr; } 

depending on way handle array of chars, might face further problems size of it.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -