Forums ProgMatique Forum Index Forums ProgMatique
Programmation (C/C++, JAVA, PHP, JavaScript, ...) et Informatique (Webmaster, Web)
Retour au site Progmatique

probleme manipulation fichier txt

 
Post new topic   Reply to topic    Forums ProgMatique Forum Index » Programmation » C / C++
Previous topic :: Next topic  
Author Message
cedm237


Offline


Joined: 12 Feb 2010
Posts: 5


PostPosted: Tue 2 Mar 2010 - 00:48    Post subject: probleme manipulation fichier txt Reply with quote

 Bonjour, j'ai fait un petit programme de manipulation entre fichier txt, et ca  fonctionne pas,les fichiers de sortie ne contienne que des zeros pourtant avec le cout je vois les données.
 
Code:

// difference.cpp : Defines the entry point for the console application.
// TotalEnergy-incident*rad_bd_0+optique*rad_bd_0

#include "stdafx.h"
#include <vector>

#include <iostream>
using namespace std;

//Variable1
const unsigned int SIZE=10000000;
int nt=2480; //header=2481, on enlève 1, on mettra nt=2480
int a,r,i;
char str[32],str1[32],str2[32],str3[32],str4[32],str5[32],str6[32],str7[32],str8[32],str9[32],str10[32];
float x, y, z, s;
struct inf1 {
  float X, Y, Z ;
  float F ;
}info1[SIZE];
struct inf2 {
  float X, Y, Z ;
  float F ;
}info2[SIZE];
struct inf3 {
  float X, Y, Z ;
  float F ;
}info3[SIZE];
struct inf4 {
  float X, Y, Z ;
  float F ;
}info4[SIZE];
struct inf5 {
  float X, Y, Z ;
  float F ;
}info5[SIZE];


int main()
{
FILE *f1 = fopen("C:\\Sample\\lens-in-totalenergy.prof", "r");
fscanf(f1, "%s %s %s \n", str1, str2, str3);         
fscanf(f1, "%s \n", str4);
       for (a=0;a<=nt;a++){
          fscanf(f1, "%f \n", &x);
          info1[a].X=x;
            };
fscanf(f1, "%s \n", str5);
fscanf(f1, "%s \n", str6);
        for (a=0;a<=nt;a++){
          fscanf(f1, "%f \n", &y);
          info1[a].Y=y;
            };
fscanf(f1, "%s \n", str7);
fscanf(f1, "%s \n", str8);
         for (a=0;a<=nt;a++){
          fscanf(f1, "%f \n", &z);
          info1[a].Z=z;
            };
fscanf(f1, "%s \n", str9);
fscanf(f1, "%s \n", str10);
         for (a=0;a<=nt;a++){
          fscanf(f1, "%f \n", &s);
          info1[a].F=s;
           };
fclose(f1);

//*******************************************************************************************

FILE *f2 = fopen("C:\\Sample\\lens-in-incidentrad-bd0.prof", "r");
fscanf(f2, "%s %s %s \n", str1, str2, str3);
fscanf(f2, "%s \n", str4);
       for (a=0;a<=nt;a++){
          fscanf(f2, "%f \n", &x);
          info2[a].X=x;
            };
fscanf(f2, "%s \n", str5);
fscanf(f2, "%s \n", str6);
        for (a=0;a<=nt;a++){
          fscanf(f2, "%f \n", &y);
          info2[a].Y=y;
            };
fscanf(f2, "%s \n", str7);
fscanf(f2, "%s \n", str8);
         for (a=0;a<=nt;a++){
          fscanf(f2, "%f \n", &z);
          info2[a].Z=z;
            };
fscanf(f2, "%s \n", str9);
fscanf(f2, "%s \n", str10);
         for (a=0;a<=nt;a++){
          fscanf(f2, "%f \n", &s);
          info2[a].F=s;
           };
fclose(f2);

//********************************************************************************************
FILE *f3 = fopen("C:\\Sample\\lens-in-opt-bd0.prof", "r");
fscanf(f3, "%s %s %s \n", str1, str2, str3);
fscanf(f3, "%s \n", str4);
       for (a=0;a<=nt;a++){
          fscanf(f3, "%f \n", &x);
          info3[a].X=x;
            };
fscanf(f3, "%s \n", str5);
fscanf(f3, "%s \n", str6);
        for (a=0;a<=nt;a++){
          fscanf(f3, "%f \n", &y);
          info3[a].Y=y;
            };
fscanf(f3, "%s \n", str7);
fscanf(f3, "%s \n", str8);
         for (a=0;a<=nt;a++){
          fscanf(f3, "%f \n", &z);
          info3[a].Z=z;
            };
fscanf(f3, "%s \n", str9);
fscanf(f3, "%s \n", str10);
         for (a=0;a<=nt;a++){
          fscanf(f3, "%f \n", &s);
          info3[a].F=s;
           };
fclose(f3);

//******************************************************************************************
for (a=0;a<=nt;a++){
       info4[a].F=info1[a].F-info2[a].F+info3[a].F;
       info5[a].F=-info4[a].F;
           };

//******************************************************************************************
FILE* fichier = NULL;
{fichier = fopen("C:\\Sample\\lens-in-heatflux.prof", "a+");
fprintf(fichier,"((lens point %d)\n",nt);
fprintf(fichier,"(x\n");
for (i=0;i<nt;i++){
x=info1[i].X;
cout<<x<<endl;
fprintf(fichier,"%.9f\n",&x);
    }
fprintf(fichier,")\n");
fprintf(fichier,"(y\n");
for (i=0;i<nt;i++){
fprintf(fichier,"%.9f\n",&info1[i].Y);
    }
fprintf(fichier,")\n");
fprintf(fichier,"(z\n");
for (i=0;i<nt;i++){
fprintf(fichier,"%.9f\n",&info1[i].Z);
    }
fprintf(fichier,")\n");
fprintf(fichier,"(lens-inheatflux\n");
for (i=0;i<nt;i++){
fprintf(fichier,"%.5f\n",&info4[i].F);
    }
fprintf(fichier,")\n");
fprintf(fichier,")\n");
fclose(fichier);
}

//********************************************************************
FILE* fichier1 = NULL;
{fichier1 = fopen("C:\\Sample\\neglens-in-heatflux.prof", "a+");
fprintf(fichier1,"((neglens point %d)\n",r);
fprintf(fichier1,"(x\n");
for (i=0;i<nt;i++){
fprintf(fichier1,"%.9f\n",&info1[i].X);
    }
fprintf(fichier1,")\n");
fprintf(fichier1,"(y\n");
for (i=0;i<nt;i++){
fprintf(fichier1,"%.9f\n",&info1[i].Y);
    }
fprintf(fichier1,")\n");
fprintf(fichier1,"(z\n");
for (i=0;i<nt;i++){
fprintf(fichier1,"%.9f\n",&info1[i].Z);
    }
fprintf(fichier1,")\n");
fprintf(fichier1,"(neglens-inheatflux\n");
for (i=0;i<nt;i++){
fprintf(fichier1,"%.5f\n",&info5[i].F);
    }
fprintf(fichier1,")\n");
fprintf(fichier1,")\n");
fclose(fichier1);
}
return 0;
}



http://www.sendspace.com/file/to3h66
http://www.sendspace.com/file/d0gtjj
http://www.sendspace.com/file/fnx8sb
Back to top
cedm237


Offline


Joined: 12 Feb 2010
Posts: 5


PostPosted: Tue 2 Mar 2010 - 01:36    Post subject: probleme manipulation fichier txt Reply with quote

resolu
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forums ProgMatique Forum Index » Programmation » C / C++ All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  

Index | Create a forum | Free support forum | Free forums directory | Report a violation | Conditions générales d'utilisation
Powered by phpBB v2 © 2001, 2005 phpBB Group ¦ Theme: subSilver++