Bonjour à tous! Je ne sais pas si il fallait se présenter sur un topic en particulier mais je me lance depuis peu dans la prog et patauge un peu d'ailleurs...
Je suis en train de faire un exercice qui consiste à faire un convertisseur decimal vers hexadecimal et vice verca.... le premier semble fonctionné mais je rencontre un probleme en compilant avec la partie hexadecimal vers décimal... voila bien 5h que je suis dessus....
A la ligne 47 de mon code, code blocks me signal un probleme : error: no match for "operator !=" (operand types are 'std::string)... Quelqu'un pourrait il me venir en aide s'il vous plait... merci beaucoup.
Ci dessous mon programme:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 #include <iostream> using namespace std; int main() { int entier, power, position ; char tabHexa[] = {"0123456789ABCDEF"} , option = 'w'; string hexa, i; while ((option != 'Q' && option != 'q')) { cout << "Convertir un décimal en hexadecimal...................1"; cout << "Convertir un hexadecimal en decimal...................2"; cout << "Pour quitter..........................................q"; if (option == '1'){ cout << " Entrez un entier ="; cin >> entier ; hexa= ""; while (entier >= 0) { if (entier < 16){ hexa= hexa + tabHexa[entier] ; entier = -1 ; } else { hexa= hexa + tabHexa[entier/16] ; entier = (entier%16) ; } } cout << "En hexadecimal, cela fait = " + hexa ; } else { if (option == '2') { cout<< "Entrez votre hexadecimal = " ; cin >> hexa ; power = 0; entier=0; while (hexa.size() > 0) { i = hexa.substr((hexa.size())-1,1) ; position = 0 ; while (i != tabHexa[position]){ position = position + 1 } entier = entier + position * 16^power ; hexa = hexa.substr(0,(hexa.size())-1); power = power + 1 ; } cout << "le resultat en decimal est = " + nombre ; } } } return 0 ; }
Partager