Mon code est le suivant, pouvez vous me dire pourquoi il n'est pas bon


Fichier.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
#pragma hdrstop
#include <condefs.h>
#include <iostream.h>
#include <conio.h>
#include "ESFichier.h"
#include <stdio.h>
 
//---------------------------------------------------------------------------
#pragma argsused
 
ESFichier *FichLire;
ESFichier *FichEcrire;
 
int main(int argc, char *argv[])
{
    char Tab[255];
    int Lig;
    FichLire = new ESFichier();
    FichEcrire = new ESFichier();
 
//****************************************************
   // Lecture d'un fichier APT
 
    // Ouverture en lecture
    FichLire->Ouvrir("programme_apt.txt","r");
    cout << "ouverture du fichier en lecture" << endl;
 
    FichLire->CompterLigne(&Lig);
    printf("Nombre de ligne : %d\n",Lig);
 
    /*//Lire une ligne n
    FichLire->LireLigne(Tab,1);
    cout << Tab << endl;
    FichLire->LireLigne(Tab,10);
    cout << Tab << endl;*/
 
    while(FichLire->Lire(Tab)!=NULL)
    {
     cout << Tab << endl;
    }
 
 
//****************************************************
 
//****************************************************
   // Ecriture d'un fichier ISO
 
      FichLire->ReplacerCurseur();
 
 
    // Ouverture du fichier en mode Ecriture
    FichEcrire->Ouvrir("programme_iso.txt","w");
    cout << "ouverture du fichier en ecriture" << endl;
 
     while(FichLire->Lire(Tab))      //tant ke l'on peu lire le fichier programme_apt.txt....
        {
                FichEcrire->Ecrire(Tab);//... on ecris dans le fichier fichier programme_iso.txt
        }
cout<<"Fichier recopier en entier"<<endl;
}
 
 
    // Fermeture
    FichEcrire->Fermer();
    FichLire->Fermer();
 
//****************************************************
 
    //attente d'une touche du clavier pour quitter l'application
    getch();
 
    return 0;
 
}
ESFichier.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "ESFichier.h"
 
 
ESFichier::ESFichier()
{
 
}
 
 
void ESFichier::Ouvrir(char *nom, char *mode)
{
	fichier = fopen (nom, mode);
       Nom=nom;
}
 
 
bool ESFichier::Lire(char *ligne)
{
	char *status;
 
 
	// sort si fichier pas ouvert
	if (fichier == NULL) return false;
 
   else {
	// initialise et lit  la ligne
	strcpy(ligne,"");
	status = fgets (ligne, TAILLE_LIGNE, fichier);
 
	// supprime l'éventuel "\n"
	if (strlen(ligne) > 0)
	{
		if (ligne[strlen(ligne)-1] == '\n') ligne[strlen(ligne)-1] = '\0';
	}
 
        return (status != NULL);
 
   }
}
 
void ESFichier::ReplacerCurseur()
{
	fseek(fichier,0,SEEK_SET);
}
 
 
bool ESFichier::Ecrire(char *ligne)
{
	int status;
 
	// sort si fichier pas ouvert
	if (fichier == NULL) return false;
 
   else {
			// ecrit  la ligne
			status = fprintf (fichier, "%s\n", ligne);
 
			// Compte rendu d'état
			return (status != (int)strlen(ligne));
   		}
 
 
}
 
void ESFichier::Fermer(void)
{
	fclose (fichier);
}
 
 
 
bool ESFichier::LireLigne(char *ligne,int numero)
{
	char *status;
        int numligne;
	// sort si fichier pas ouvert
	if (fichier == NULL) return false;
 
   else {
	// initialise et lit  la ligne
	strcpy(ligne,"");
 
         for (numligne=0;numligne<numero;numligne++)
         {
	status = fgets (ligne, TAILLE_LIGNE, fichier);
         }
	// supprime l'éventuel "\n"
	if (strlen(ligne) > 0)
	{
		if (ligne[strlen(ligne)-1] == '\n') ligne[strlen(ligne)-1] = '\0';
	}
 
	return (status != NULL);
 
 
 
   }
}
 
void ESFichier::CompterLigne(int *nbligne)
{
 
char *Stat="1";
char ligne2[255];
*nbligne=-1;
 
 
while(Stat!=NULL)
        {
        *nbligne=*nbligne+1;
        Stat = fgets (ligne2, TAILLE_LIGNE, fichier);
        }
 
 
}
ESFichier.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
#ifndef ESFichier_H
#define ESFichier_H
 
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <algorithm>
 
#define TAILLE_LIGNE 255
 
class ESFichier
{
private:
	FILE *fichier;
        char *Nom;
public:
	ESFichier();
        void Ouvrir(char *, char *);
        void Fermer(void);
	bool Lire(char *);
	bool Ecrire(char *);
        bool LireLigne(char*,int numero);
        void CompterLigne(int *);
        void ReplacerCurseur();
 
};
#endif
Merci je bataille depuis lomgtemps