Hi!
I need to use the string::substr function, but its header says:
basic_string substr( size_t index, size_t num );
Canīt I just pass an int or an iterator???
Hi!
I need to use the string::substr function, but its header says:
basic_string substr( size_t index, size_t num );
Canīt I just pass an int or an iterator???
Nothing more to tell about me...
Happy day =)
Yes, you can just pass an int. size_t is usually just a typedef'd unsigned int.
Thanks!!! I didnīt know the typedef stuff!!
Jut one more question: and if I am using iterators to search the string? What can I do?
I need this thing because I am making a parser.
Last edited by gustavosserra; 08-30-2003 at 03:49 PM.
Nothing more to tell about me...
Happy day =)
"and if I am using iterators to search the string?"
You don't get to decide what parameters you're going to pass the function: the function is defined to take two int parameters.
You can try subtracting iterators:
I'm not sure about the portability of this, so your mileage may vary.Code:string s = str.substr(itr - str.begin(), len);
Really thanks!!!
Nothing more to tell about me...
Happy day =)