Hi
given a coma delimited string "abc.,def.,ghj. ,my name is", I need to
get the output
//output
abc.
def.
jhj.
my name is
here is how I did it but it is messy. I hope someone came up with a
cleaner version.
thank you
short Conn_task::prin t_smi(const string& s){
short itm = 0;
int from =0;
int sz = 0;
while( from <= s.rfind(",") ){
if( sz = s.find(",", from) )
cout << "[" << itm << "] " << s.substr(from, sz-from) << endl;
from =sz+1;
++itm;
}
cout << itm << s.substr(from, s.length()-from) << endl;
}
Comment