PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > chopping strings
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
chopping strings

Réponse
 
LinkBack Outils de la discussion
Vieux 17/10/2007, 16h17   #1
djm
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut chopping strings

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

  Réponse avec citation
Vieux 17/10/2007, 16h27   #2
Shadowman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chopping strings

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
  Réponse avec citation
Vieux 17/10/2007, 16h53   #3
djm
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chopping strings

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;

  Réponse avec citation
Vieux 17/10/2007, 18h43   #4
Default User
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chopping strings

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h20.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07878 seconds with 12 queries