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
| #include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
double a[50][50];
double tps[15];
double autre[15];
double vit[15];
FILE *file;
int i; int j; int k;
char ligne[50];
char line[50];
char *p;
char sep[10];
strcpy(sep,"; ");
if( (file = fopen("nb.txt", "r")) == NULL){printf("erreur ouverture fichier\n");exit(1);}
i=j=0;
while(fgets(ligne, sizeof(ligne),file)!= NULL){
printf("%s", ligne);
strcpy(line,ligne);
p = strtok(line, sep);
do{
printf("%s\n",p);
printf("%lf\n",atof(p));
a[i][j]=atof(p);
printf("a[%d][%d] vaut %lf\n",i,j,a[i][j]);
p = strtok(NULL, sep);
j++;
}while(p != NULL);
j=0;
i++; //jusqu'a la, tout marche
}
fclose(file);
printf("\nok\n"); //ne marche plus, meme le printf ne s'affiche pas
for(k=0;k<=i;k++){
tps[k]=a[k][0];
autre[k]=a[k][1];
vit[k]=a[k][2];
}
printf("\n%lf, %lf, %lf\n", tps[0], vit[0], autre[0]);
return 0;
} |
Partager