bonjour, j'ai 2 variable qui doivent comparer si elles sont identique mais elle retourne toujours vrai meme quand elle ne sont pas du tout identique. ca fait 2 semaine que je galere sur ce probleme. les deux variables sont dans le fichier facile.cpp a la ligne 61.

voici les fichiers

facile.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "Facile.h"
#include "Mot.h"
 
Facile::Facile()
{
    //Fabrication de la fenetre de niveau facile
    QDesktopWidget bureau;
    QRect surface_bureau = bureau.screenGeometry();
    int x = surface_bureau.width()/2 - width()/2;
    int y = surface_bureau.height()/2 - height()/2;
    move(x,y);
 
    setWindowTitle("Folie Lettre en mode Facile");
    setWindowIcon(QIcon("Data/Images/earth.gif"));
 
    btnValider = new QPushButton("Valider");
    btnEntendre = new QPushButton("Entendre le son a nouveau");
    boxImage = new QLabel;
    Solution = new QLabel("");
    Reponse = new QLineEdit();
    layoutFacile = new QVBoxLayout;
    layoutBoutons = new QHBoxLayout;
    temporaire = new QLabel;
 
    layoutBoutons->addWidget(btnValider);
    layoutBoutons->addWidget(btnEntendre);
 
    layoutFacile->addWidget(temporaire);
    layoutFacile->addWidget(Solution);
    layoutFacile->addWidget(Reponse);
    layoutFacile->addLayout(layoutBoutons);
    setLayout(layoutFacile);
    coupRestants = 10;
    Jouer();
 
}
 
void Facile::Jouer()
{
    motMystere = ("");
    motMystere = Mot::TrouverMot("Data/Dictio/dictiofacile.txt");
 
    Solution->setText("Comment ça doit s'écrire?");
    motJoueur = Reponse->text();
    temporaire->setText("motMystere=" + motMystere);
 
 
    QObject::connect(btnValider, SIGNAL(clicked()), this, SLOT(Gagne()));
    QObject::connect(btnEntendre, SIGNAL(clicked()), this, SLOT(Encore()));
}
 
void Facile::Gagne()
{
    strcpy(motJoueur, mot1.toAscii().data());
    strcpy*(motMystere, mot2.toAscii().data());
 
    if (Reponse->text().isEmpty())
        QMessageBox::critical(this, "Erreur", "Tu doit entrer au moins un mot");
        coupRestants--;
 
    if (QString::compare(mot1, mot2) == 0)
        QMessageBox::information(this, "Erreur", "cool.");
    else
        QMessageBox::critical(this, "Erreur", "Désolé, ce n'est pas comme ca.");
 
 
 
}
 
void Facile::Encore()
{
    motMystere = ("");
    motMystere = Mot::TrouverMot("Data/Dictio/dictiofacile.txt");
}
facile.h
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
#ifndef HEADER_FACILE
#define HEADER_FACILE
 
#include <QtGui>
#include <QWidget>
#include <QApplication>
#include <QTextEdit>
#include <QFile>
#include <QString>
#include <QTextStream>
#include <QLineEdit>
#include <QString>
 
class Facile : public QWidget
{
    Q_OBJECT
 
 
    public:
        Facile();
        void Jouer();
 
    public slots:
        void Gagne();
        void Encore();
 
    private:
    QVBoxLayout *layoutFacile;
    QHBoxLayout *layoutBoutons;
    QPushButton *btnValider;
    QPushButton *btnEntendre;
    QLabel *Solution;
    QLineEdit *Reponse;
    QLabel *boxImage;
    QLabel *temporaire;
 
    QString motMystere;
    QString motJoueur;
    QString son;
    QString image;
    char* mot1;
    char* mot2;
 
    long longMot;
    bool bonMot;
    long coupRestants;
 
 
};
 
#endif
mot.h
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
#ifndef H_MOT
#define H_MOT
 
#include <QtGui>
#include <fstream>
 
class Mot
{
    public :
    Mot();
    static QString TrouverMot(char* fichierdictio);
 
 
    private :
 
};
 
#endif
mot.cpp
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
#include "Mot.h"
 
using namespace std;
 
Mot::Mot()
{
    qsrand(time(NULL));
 
}
 
QString Mot::TrouverMot(char* fichierdictio)
{
    int MAX = 0;
    char caractere = 0;
 
    QFile filz(fichierdictio);
 
    if (!filz.open(QIODevice::ReadOnly))
        return ("ERROR");
    QTextStream fichier(&filz);
 
    // Compte du nombre de mots
    while (!fichier.atEnd())
    {
        fichier >> caractere;
 
        if (caractere == '\n')
            MAX++;
    }
 
    fichier.seek(0);
 
    // Definition du nombre aléatoire
    // et positionnement dans le fichier
    int ligneAleat = rand() % MAX;
    int t = 0;
 
    while (t != ligneAleat)
    {
        fichier >> caractere;
        if (caractere == '\n')
            t++;
    }
 
    // Retour du mot selectionné
    QString mot;
    fichier >> mot;
 
    return mot;
}