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
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fic1, *fic2;
char ligne_lue[512];
char centre[255];
char XYZ[255];
float x, y, z;
// ouverture du fichier passé en argument
fic1 = fopen(argv[1], "r"); // ouvrir en lecture
// recuperer les donnees du centre
int nb_lignes = 0;
while(fgets(ligne_lue, 512, fic1) != NULL)
{
if (strstr(ligne_lue, "<Centre>"))
{
strcpy(centre, ligne_lue);
nb_lignes++;
}
}
printf(centre);
// centre = <Centre>-1.97873759985943254 -5.74970454086871108 9.11020907274524383</Centre>
sscanf(centre, "<Centre>%f %f %f</Centre>", &x, &y, &z);
printf("\nx: %f y: %f z: %f\n", x, y, z);
return 0;
} |
Partager