Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3019 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  convertir en maj avec la fonction toupper

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

convertir en maj avec la fonction toupper

n°1026253
jaybolo
Posté le 26-03-2005 à 20:21:02  profilanswer
 

bonjour,  
 
je vous poste de message car  j'ai un petut souci dans mon code qui me dépasse. je dois faire un code en c++ qui doit affiché en majuscule sur la sortie standard les caractères tapés en entré standard.  
voici le code source

Code :
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. #include <iterator>
  6. using std::vector;
  7. std::string Maj (std::string & a)
  8. {
  9.     return toupper(a);
  10. }
  11. int main(void)
  12. {
  13.     vector<std::string> data;
  14.     std::copy(std::istream_iterator<std::string>(std::cin),
  15.             std::istream_iterator<std::string>(),
  16.             back_inserter (data));
  17.     std::transform(data.begin(), data.end(), std::ostream_iterator<std::string>(std::cout, "\n" ), Maj);
  18.     return 0;
  19. }


 
et j'obtiens ça comme message de compilation  
 
jaybolo[20:12][f-upper]make re
rm -f upper.o *~
g++ -O2 -Wall -W -Werror   -c -o upper.o upper.cpp
upper.cpp: In function `std::string Maj(std::string& )':
upper.cpp:23: error: no matching function for call to `toupper(
   std::basic_string<char, std::char_traits<char>, std::allocator<char> >& )'
/usr/include/ctype.h:119: error: candidates are: int toupper(int)
make: *** [upper.o] Error 1
jaybolo[20:13][f-upper]
 
 
Je compile grâce à g++ sous une debian.
 
Si quelqu'un voit où je me suis gourré ce serait coool de me le faire savoir svp.
 
merci d'avance

mood
Publicité
Posté le 26-03-2005 à 20:21:02  profilanswer
 

n°1026305
Rits75
to?be:!be
Posté le 26-03-2005 à 21:09:34  profilanswer
 

upper.cpp:23: error: no matching function for call to `toupper(
   std::basic_string<char, std::char_traits<char>, std::allocator<char> >& )'
/usr/include/ctype.h:119: error: candidates are: int toupper(int)  
 
--> il te dit qu'il ya pas de fonction toupper qui prend en param une string!  
 
man toupper

n°1026325
Rits75
to?be:!be
Posté le 26-03-2005 à 21:27:52  profilanswer
 

man toupper
pour qu'il voit a quoi sert la fonction, mais bon la solution n'est pas loin, il suffit de upper tous les caracters de la chaine dans Maj!

n°1026341
Joel F
Real men use unique_ptr
Posté le 26-03-2005 à 21:43:20  profilanswer
 

http://www.boost.org/doc/html/stri [...] l#id576240


Message édité par Joel F le 26-03-2005 à 21:43:47
n°1026375
Joel F
Real men use unique_ptr
Posté le 26-03-2005 à 22:07:15  profilanswer
 

annadivx a écrit :

lol...
si son prof lui à demandé d'utiliser string.h ;) ...


 
ben son prof est un incompetent :o

n°1026619
Rits75
to?be:!be
Posté le 27-03-2005 à 09:11:58  profilanswer
 

allez suis gentil lol
 
# std::string Maj (std::string & a)
# {
#    std::transform(a.begin(), a.end(), a.begin(), toupper);
#    return a
# }
 
la  suite devrait marché en ajoutant ctype.h pour toupper

n°1027236
jaybolo
Posté le 28-03-2005 à 12:56:10  profilanswer
 

salut
 
merci pour ton aide rits75, il marche mon programme,  
 
merci encore

Rits75 a écrit :

allez suis gentil lol
 
# std::string Maj (std::string & a)
# {
#    std::transform(a.begin(), a.end(), a.begin(), toupper);
#    return a
# }
 
la  suite devrait marché en ajoutant ctype.h pour toupper


Message édité par jaybolo le 28-03-2005 à 12:56:37

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  convertir en maj avec la fonction toupper

 

Sujets relatifs
valeur de <input text> en fonction d'un <select>convertir un string en bit
Fonction 'atoi()" en Ada [RESOLU]Fonction à nombre paramètres variables
Fonction lancer au démarrage d'une application visual c++ .NETProtection par .htaccess ou par une fonction PHP?
appeler une fonction PHP suite à un clic ?[JSP] Fonction globale ?
pb avec les accents dans la fonction mailcomment marche la fonction "fseek" en C?
Plus de sujets relatifs à : convertir en maj avec la fonction toupper


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR