| 12
 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
 
 | #include <string>
#include <fstream>
#include <iostream>
#include <stdio.h>
using namespace std;
typedef struct termes{
	 string terme;
}termes;
termes index[32414];
 
//int * p2 = new termes;
int main()
{
 
    // le constructeur de ifstream permet d'ouvrir un fichier en lecture
    std::ifstream fichier( "Liste_mots.txt" );
 
   int k,i=0,j;
    if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
    {
       // std::string ligne, terme; // variable contenant chaque ligne lue
          std::string ligne, termet; // variable contenant chaque ligne lue
 
        // cette boucle s'arrête dès qu'une erreur de lecture survient
        std::getline( fichier, ligne );
 
        k=ligne.length(); 
 
        //termet.assign(ligne, 0,ligne.length());
 
 
        index[i].terme.assign(ligne, 0,ligne.length());
     // i++;
        while ( std::getline( fichier, ligne ) )
        {
            i++;
             if(ligne.length() > k ){
             	 k=ligne.length(); 
             	// termet.assign(ligne, 0,ligne.length());
 
			 }         
 
            index[i].terme.assign(ligne, 0,ligne.length());
        }
        std::cout << i<< std::endl;
 
        termet.assign(index[i].terme,0,index[i].terme.length());
       // std::cout << termet << std::endl;
        /*
        for(j=0;j<=i;j++){
                          std::cout << index[j].terme << std::endl;
        }
       */
 
        printf("k=   %d\n",k);
 
        printf("sizeof(index)      = %d\n", sizeof(index));
 
        do{}while(1!=2);
    }    
 
 
} | 
Partager