|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
hello everyone. ive a string with a blank space at the start
for eg: string str=" c++ rocks!"; how can i chop of that blank space of the string and display? thanks |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
djm wrote:
> hello everyone. ive a string with a blank space at the start > for eg: > string str=" c++ rocks!"; > how can i chop of that blank space of the string and display? > thanks > Use some combination of one or more of: string::find string::find_first_of string::erase -- SM rot13 for email |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Oct 17, 8:27 pm, Shadowman <funqbjzna...@pbzpnfg.arg> wrote:
> djm wrote: > > hello everyone. ive a string with a blank space at the start > > for eg: > > string str=" c++ rocks!"; > > how can i chop of that blank space of the string and display? > > thanks > > Use some combination of one or more of: > > string::find > string::find_first_of > string::erase > > -- > SM > rot13 for email thanks shadow man. i used string::erase to do it did it like this string str (" c++ rocks!"); str.erase (0,1); cout << str << endl; |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
djm wrote:
> On Oct 17, 8:27 pm, Shadowman <funqbjzna...@pbzpnfg.arg> wrote: > > djm wrote: > > > hello everyone. ive a string with a blank space at the start > > > for eg: > > > string str=" c++ rocks!"; > > > how can i chop of that blank space of the string and display? > > > thanks You can call it that if you want, but usually "chop" means to remove the last character of a string. I've seen "ltrim" for removing leading characters, there are probably other names. > thanks shadow man. i used string::erase to do it > did it like this > > string str (" c++ rocks!"); > str.erase (0,1); > cout << str << endl; This will always remove the first character (and only that one), regardless of whether it's whitespace or not. Is that what you want? Brian |
|
![]() |
| Outils de la discussion | |
|
|