output file

i am trying to output my file into a chart form but when i output the information is not all on the same line

1
2
3
4
5
6
7
8
9
10
11
12
  void outputArray(element elements[], const int SIZE){
    //do 4 row 5 columns
    //modulus solution
    for (int i = 0; i < SIZE; i++){
        cout << setw(5) << elements[i].name;
        cout<< setw(12)<< elements[i].symbol;
        cout<< setw(15)<< elements[i].number;
        cout << setw(20)<< elements[i].meltingPoint;
        cout << setw(25)<< elements[i].boilingPoint;
            cout << endl;
        }
    }


the full code is this
[code]
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

struct element {
char name[22];
char symbol[4];
char number[4];
char meltingPoint[12];
char boilingPoint[8];

};
/******************************prototypes************************************/
void readfile (element elements[], const int SIZE);
void outputArray(element elements[], const int SIZE);

int main(){
const int SIZE = 118;
element elements[SIZE];
readfile (elements, SIZE);
outputArray(elements, SIZE);

return 0;
}

/****************************functions*********************************/
void readfile (element elements[], const int SIZE)
{
ifstream infile ("elementsAssign-3.txt");
if (infile)
{

for (int i = 0; i < SIZE && !infile.eof (); i++)
{
infile.getline (elements[i].name, SIZE);
infile.getline (elements[i].symbol, SIZE);
infile.getline (elements[i].number, SIZE);
infile.getline (elements[i].meltingPoint,SIZE);
infile.getline (elements[i].boilingPoint, SIZE);
}

infile.close ();
}
else
cout << "file not found" << endl;

}
[code\]
output looks like this
Actinium
Ac
Ac
89
1922
5788
Aluminum (Aluminium)
Al
Al
13
1220.581
4566
Topic archived. No new replies allowed.