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
| #include<stdio.h>
#include<stdlib.h>
int main(int argc, char * argv [])// argc nb chaines caract, argv pointeur chaine
{
double laf, temp, st, ast;
char c;
char entree[255], sortie[255];
FILE *in, *out;
if(argc>1)
in = fopen(argv[1], "r");
if(argc==1 || in == NULL)
in = fopen("entree", "r");
if (in == NULL) {
fprintf(stderr, "Erreur in\n");
exit(1);
}
if(argc>2)
out = fopen(argv[2], "w");
if(argc<=2 || in == NULL)
out = fopen("sortie", "w");
if (out == NULL) {
fprintf(stderr, "Erreur out\n");
exit(1);
}
else
{
//fprintf(out, "| LAF\t| Temperature\t| Stokes \t\t| Antistokes\t| Stockes/Antistokes\t\n|\t\t|\t\t\t\t|\t\t\t\t|\t\t\t\t|\t\t\t\t\t\t|\n");
fprintf(out, "\"LAF\", \"Temperature\", \"Stokes\", \"Antistokes\", \"Stockes/Antistokes\";\n");
while ((c = fgetc(in)) != EOF)
{
if(fscanf(in, "<data id=\"1\">%lf,%lf,%lf,%lf</data>", &laf, &temp, &st, &ast) == 4)
//fprintf(out, "| %05.1lf\t| %010.6lf\t| %012.6lf\t| %012.6lf\t| %012.6lf\t|\n|\t\t|\t\t\t\t|\t\t\t\t|\t\t\t\t|\t\t\t\t\t\t|\n", laf, temp, st, ast, st/ast);
fprintf(out, "\"%05.1lf\", \"%010.6lf\", \"%012.6lf\", \"%012.6lf\", \"%05.6lf\";\n", laf, temp, st, ast, st/ast);
}
}
return 0;
} |