Two files to be one file

if I have the two attached files, with the same X axes,
How can i make a new output file contain the same X and the sum of Y? and Draw the results in Histograme?


I think you need to read in the content of the files (this is not a root specific task) and then fill a histogram (you can educate yourself here I think


I already send you an example which does the reading and writing of a two columns ascii file . Start from that. You only need to create a 1D histogram and fill it. The page @Pnine pointed gives you plenty of examples showing how to do this simple task.

the last example with one input file, but here i have two input files. same X and different y, i want to generate anew file with X and the sum of Y

Open the two file you need to read using:

   ifstream inputfile1;"data1.txt");
   ifstream inputfile2;"data2.txt");

can you modify please ?

adding.C (375 Bytes)

the loop should be:

   while (inputfile1 >> E1 >> C1) {
      inputfile2 >> E2 >> C2;
      C = C1+C2;
      outputfile << E1 << "               " << C <<endl;

Thanks Alot,

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.