Bonjour à tous,
J'essaie de créer un programme qui m'aidera a apprendre toutes genres de choses. Voici son code source:
main.cpp:
chargerFichier.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 #include <iostream> #include <fstream> #include <string> #include <compterLignesFichier.h> #include <chargerFichier.h> #include <plusPetit.h> #include <questionReponse.h> using namespace std; int main() { cout << "Bonjour et bienvenue dans ce programme d'apprentissage. Veuillez indiquer depuis quel fichier vous souhaitez travailler:" << endl; string nomFichier(""); cin >> nomFichier; int lignes=compterLignesFichier(nomFichier); string fichier[lignes]; chargerFichier(nomFichier,fichier); unsigned int nombreReussite[lignes]; while(true) { for(int i=0;i<lignes;i++) { if(plusPetit(nombreReussite[],i,lignes)) questionReponse(fichier[i]); } } return 0; }
compterLignesFichier.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 void chargerFichier(std::string nomFichier,std::string & file[]) { std::string nomFichier; std::string file[]; std::ifstream fichier(nomFichier.c_str()); if(fichier) { int i=0; while(getline(fichier,file[i])) { i++; } } else { cout << "ERREUR: Impossible d'ouvrir le fichier en lecture." << endl; } }
plusPetit.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 void chargerFichier(std::string nomFichier,std::string & file[]) { std::string nomFichier; std::string file[]; std::ifstream fichier(nomFichier.c_str()); if(fichier) { int i=0; while(getline(fichier,file[i])) { i++; } } else { cout << "ERREUR: Impossible d'ouvrir le fichier en lecture." << endl; } }
questionReponse.cpp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 bool plusPetit(int nombreReussite[],int Reference,int tailleTableau) { bool petit=true; for(int i=0;i<tailleTableau;i++) { if(nombreReussite[Reference]>nombreReussite[i]) petit=false; } return petit; }
Voici ce que mon compilateur m'affiche:
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 void questionReponse(std::string fichier) { std::string reponse(""); int i=0; for (i=0;fichier[i]!='\t';i++) cout <<fichier[i]; cin >>reponse; bool vrai=true; i++; int j=i; for (;fichier[i]!='\n';i++) { if(fichier[i]!=reponse[i-j]) vrai=false; } if(!vrai) { for (int p=0;fichier[p]!='\n';p++) { cout << fichier[p]; } } else cout <<"Bien joué"; }
||=== Build: Debug in azerty (compiler: GNU GCC Compiler) ===|
/home/christophe/codebloks/azerty/chargerFichier.cpp|1|error: variable or field ‘chargerFichier’ declared void|
/home/christophe/codebloks/azerty/chargerFichier.cpp|1|error: ‘string’ is not a member of ‘std’|
/home/christophe/codebloks/azerty/chargerFichier.cpp|1|error: ‘string’ is not a member of ‘std’|
/home/christophe/codebloks/azerty/chargerFichier.cpp|1|error: ‘file’ was not declared in this scope|
/home/christophe/codebloks/azerty/chargerFichier.cpp|1|error: expected primary-expression before ‘]’ token|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Qui peux me dire ou sont les Erreurs? Et quelles sont-elles?
Partager