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
|
#include "stdafx.h"
#include <sstream>
#include <fstream>
using namespace std;
main()
{
double *tab=new double [1000000];
string *tab1;
tab1=new string [10];
tab1[0]="toto0.txt";
tab1[1]="toto1.txt";
for(int i=0;i<2;i++)
{
cout<<"tab1["<<i<<"]="<<tab1<<endl;
ifstream fichier( tab1 );
int nbElement = 0;
if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
{
string ligne; // variable contenant chaque ligne lue
while ( getline( fichier, ligne,';') )
{
stringstream s;
s << ligne;
double n;
s >> n;
tab[nbElement]=n;
nbElement++;
}
}
}
} |
Partager