c++ - String pointer manipulation -


i have assignment @ school. string pointer passed function , returns 2 const strings different functions.
2 new strings divide original string 2 parts based on space.
example:
input

str = 05/12 hello   

desired output

key = 05/12   satdata = hello 

this code wrote giving me errors. please help

void rbapp::processinsert(string &str) {   string *key = new string();   string *satdata = new string();   int = 0, j =0;   while(str[i]!=" ")   {     key[j] = str[i];     i++;     j++;   }   j = 0;   while(str[i]!='\0')   {     satdata[j] = str[i];     i++;     j++;   }   myrbt.rbinsert(key, satdata); } 

using stringstream

void rbapp::processinsert(const std::string &str) {   std::stringstream ss(str);    std::string key;   std::string satdata;    ss >> key;   ss >> satdata;   myrbt.rbinsert(key, satdata); } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -