output design

Hi every body

I want to know how to arrange my output file to be lik every variable in a seperate column and the head is the name of that variable .

since what I got is

E in ev =5431'.'x-position in cm =0'.'y-position in cm =0'.'z-position in cm =-3.5.'

E in ev =5426'.'x-position in cm =0'.'y-position in cm =0'.'z-position in cm =-3.'

E in ev =5411'.'x-position in cm =0'.'y-position in cm =0'.'z-position in cm =-2.5.'

E in ev =5406'.'x-position in cm =0'.'y-position in cm =0'.'z-position in cm =-2'

.
.
.
etc

my code is


#include <iostream>
#include <fstream>
using namespace std;
std::ofstream WriteDataIn ("mamdouh.txt" , std::ios::app);
WriteDataIn
<<std::setw(0)<<"E in ev ="<<""<<std::setw(0)<<edepStep<<"'\t'"
<<std::setw(0)<<"x-position in cm ="<<""<<std::setw(0)<<x<<"'\t'"
<<std::setw(0)<<"y-position in cm ="<<""<<std::setw(0)<<y<<"'\t'"
<<std::setw(0)<<"z-position in cm ="<<""<<std::setw(0)<<z<<"'\t'"
<<G4endl;

I do appreciate your thoughts on this .
Sorry can't get the output to format right in the forum but it looks right on the command line.

Maybe you want something like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <fstream>
using namespace std;

int main ()
{
int x=0;
int y=10000;
int z=100000000;
int EV=5431;

cout <<"E in ev"<<"\t"<<"x-position"<<"\t" <<"y-position"<<"\t"<<"z-position"<<endl;
cout <<"\t"<<"     in cm"<<"\t" <<"     in cm"<<"\t"<<"     in cm"<<endl;
cout <<"-------"<<"\t"<<"----------"<<"\t" <<"----------"<<"\t"<<"----------"<<endl;

cout << EV <<"\t"<< x <<"\t\t" << y <<"\t\t" << z <<endl;

return 0;
}

Last edited on
Topic archived. No new replies allowed.