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

My HTML document is not linking to my CSS stylesheet properly -

php array slice every 2th rule -

node.js - Sending sockets to client side, Error: Converting circular structure to JSON -