Bonjour à tous,
j'ai actuellement un problème avec un vecteur de string. Ce dernier me fait planté mon programme je ne sais pourquoi alors qu'il est compilé. Windows(7) me met que le programme a cesser de fonctionner ...
Voici l'intégralité de mon code :
Code c++ : 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
#include<iostream>
#include<conio.h>
#include<math.h>
#include<iomanip>
#include<string>
#include<fstream>
#include <cstring>
#include <vector>
 
using namespace std;
 
int main()
{
     int nbLigne;
     string chaine;
     vector<string> tableau;
     // recuperation du fichier *******************************************
     ifstream fichier("C:\\log.txt",ios::in);
 
     if (!fichier.fail())
     {
        string ligne;
        int nbLigne=0;        
        while(getline(fichier, ligne)) 
        {  
          tableau[nbLigne]=ligne;
          nbLigne++;
        }
      }
      else
      {
       cout << " Problème fichier log.txt \n";
      }
      fichier.close() ;
      // Fin recuperation du fichier ***************************************
      cout << tableau.size();     
      getch();
      return(0);
}
Et voici la ligne qui pose problème :
Code c++ : Sélectionner tout - Visualiser dans une fenêtre à part
tableau[nbLigne]=ligne;