A voir également:
- Changement de casse en c++
- Piratage facebook changer mot de passe - Guide
- Changer clavier qwerty en azerty - Guide
- Changement d'écriture - Guide
- Changer de dns - Guide
- Changement carte graphique - Guide
2 réponses
Mahmah
Messages postés
496
Date d'inscription
lundi 17 septembre 2007
Statut
Membre
Dernière intervention
22 juin 2010
125
22 mars 2008 à 18:11
22 mars 2008 à 18:11
Bonjour,
Pour un truc qui ait une gueule de C++ plus que du C il y a:
(Oui bon, okay, tolower j'ai pas trouvé l'équivalent en C++...)
il y a certainement aussi moyen de faire une boucle sur la taille aussi...
M.
Pour un truc qui ait une gueule de C++ plus que du C il y a:
#include <cstdio> // Pour le getchar() #include <iostream> #include <string> #include <algorithm> void myToLower( char &rc ) { rc = tolower( rc ); } int main( int argc, char *argv[]) { std::string sBlabla( "BlaBla" ); std::cout << sBlabla << std:: endl; // for ( std::string::iterator iter = sBlabla.begin() ; iter != sBlabla.end() ; iter++ ) // (*iter) = tolower( *iter ); // Ou alors : (Le premier évite l'écriture de myToLower) std::for_each( sBlabla.begin(), sBlabla.end(), myToLower ); std::cout << sBlabla << std:: endl; getchar(); return 0; }
(Oui bon, okay, tolower j'ai pas trouvé l'équivalent en C++...)
il y a certainement aussi moyen de faire une boucle sur la taille aussi...
for ( unsigned int i = 0 ; i != sBlaBla.size() ; i ++ ) sBlaBla[i] = tolower( sBlaBla[i] );
M.
Cadeau
//mettre un string tout en minuscule void toLower(string *chaine) { for(unsigned int i=0; i<chaine->size(); i++) { if ( chaine->at(i) >= 65 && chaine->at(i) <= 90 ) { chaine->at(i) += 32; } } } //mettre un string tout en majuscule void toUpper(string *chaine) { for(unsigned int i=0; i<chaine->size(); i++) { if ( chaine->at(i) >= 97 && chaine->at(i) <= 122 ) { chaine->at(i) -= 32; } } }