C++ decimal, hexa , string ..
Fermé
newram66
Messages postés
9
Date d'inscription
vendredi 19 mars 2010
Statut
Membre
Dernière intervention
29 avril 2010
-
6 avril 2010 à 13:22
newram66 Messages postés 9 Date d'inscription vendredi 19 mars 2010 Statut Membre Dernière intervention 29 avril 2010 - 6 avril 2010 à 19:01
newram66 Messages postés 9 Date d'inscription vendredi 19 mars 2010 Statut Membre Dernière intervention 29 avril 2010 - 6 avril 2010 à 19:01
A voir également:
- C++ decimal, hexa , string ..
- Printf hexa - Forum Programmation
- Editeur hexa - Télécharger - Édition & Programmation
- Cannot access offset of type string on string - Forum PHP
- Uninitialized string offset ✓ - Forum PHP
- Include string - Forum C++
2 réponses
Char Snipeur
Messages postés
9688
Date d'inscription
vendredi 23 avril 2004
Statut
Contributeur
Dernière intervention
2 octobre 2020
1 328
6 avril 2010 à 14:10
6 avril 2010 à 14:10
Salut.
Tu peux essayer les flux de string : https://en.cppreference.com/w/cpp/io/basic_stringstream/operator%3D
Par contre, je ne suis pas certain qu'il comprenne l'hexadécimal aussi simplement.
Peut être en spécifiant le flag hex https://en.cppreference.com/w/cpp/io/ios_base/flags
ou en utilisant le formalisme "0xFF"
Tu peux essayer les flux de string : https://en.cppreference.com/w/cpp/io/basic_stringstream/operator%3D
Par contre, je ne suis pas certain qu'il comprenne l'hexadécimal aussi simplement.
Peut être en spécifiant le flag hex https://en.cppreference.com/w/cpp/io/ios_base/flags
ou en utilisant le formalisme "0xFF"
newram66
Messages postés
9
Date d'inscription
vendredi 19 mars 2010
Statut
Membre
Dernière intervention
29 avril 2010
6 avril 2010 à 19:01
6 avril 2010 à 19:01
merci beaucoup
en fait j'ai codé une fonction qui répond au besoin
si quelqu'un en a besoin :
int convertStringToInt(string s){
char tab[]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9','A','B','C','D','E','F'};
int a0,a1;
for (int i=0;i<16;i++)
{
if (toupper((s.at(0))) == tab[i]) a0 = i;
if (toupper((s.at(1))) == tab[i]) a1 = i;
}
return(a0*16+a1);
}
salut
en fait j'ai codé une fonction qui répond au besoin
si quelqu'un en a besoin :
int convertStringToInt(string s){
char tab[]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9','A','B','C','D','E','F'};
int a0,a1;
for (int i=0;i<16;i++)
{
if (toupper((s.at(0))) == tab[i]) a0 = i;
if (toupper((s.at(1))) == tab[i]) a1 = i;
}
return(a0*16+a1);
}
salut