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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
using namespace std;
const int NUM_FILE = 20;
string converter (double ms,int index,string nome);
int main()
{
string parag[200],str,file[NUM_FILE],filevar;
string nomemass;
double massf, massData;
ifstream inn[NUM_FILE],inVar;
ofstream outt[NUM_FILE][200],outintest[NUM_FILE][200];
cout << "File contenente le variabili: ";
getline(cin,filevar);
inVar.open(filevar.c_str());
cout << "Inserire i nomi dei file di input(terminare dando la barra spaziatrice): ";
int ord=-1;
do
{
ord++;
getline(cin,file[ord]);
}while (file[ord] != " ");
int k = 0;
inVar.ignore(2000, ')');
inVar >> massf; // massa cercata dall'utente
while(!inVar.eof())
{
massf = massf + 1.0079;
nomemass = converter(massf,k,nomemass);
for(int j=0; j<ord; j++)
{
inn[j].open(file[j].c_str());
outt[j][k].open(string("Out" + nomemass + file[j]).c_str());
outintest[j][k].open(string("Intest"+ nomemass + file[j]).c_str()); // apro file output con solo intestazioni
while(inn[j])
{
A long portion of code that I don't report but that works (I tested it)
}
}
k++;
inVar.ignore(2000,')');
inVar >> massf;
}
return 0;
}
string converter(double ms,int index,string nome)
{
ostringstream os[200];
double massaconvert = ms;
os[index] << massaconvert; // trasformo la massa(double) in string per chiamare il file con la massa
nome = os[index].str();
return nome;
}
|