reading double from a binary file (into a class) - decimals do not show
<p>having trouble displaying the decimals after reading the data.</p>

<p>As the title says.. here are some code snippets.  </p>

<p>the header for the student obj</p>

<pre><code>class StudentRecordData
{
protected:
   double Marks[MAX_COURSES];
   unsigned int Age;
   unsigned int ID;
   unsigned int CourseCount;
   char FirstName[LEN_FN];
   char LastName[LEN_FN];
   Course  Courses[MAX_COURSES];
};
</code></pre>

<p>student header:</p>

<pre><code>class Student : public StudentRecordData {

public:
    double *getMarks();
    unsigned int getAge();
    unsigned int getID();
    unsigned int getCourseCount();
    char *getFirstName();
    char *getLastName();
    Course *getCourses();
    double getAverage();

    int operator &lt; (Student &amp;);
    int operator &lt; (const char &amp;);
};
</code></pre>

<p>Student implementation (inherited the above)</p>

<pre><code>#include "Student.h"
#include &lt;iostream&gt;
#include &lt;cstring&gt;
using namespace std;

double *Student::getMarks() {
    return Marks;
}

unsigned int Student::getAge() {
    return Age;
}

unsigned int Student::getID() {
    return ID;
}

unsigned int Student::getCourseCount() {
    return CourseCount;
}

char *Student::getFirstName() {
    return FirstName;
}

char *Student::getLastName() {
    return LastName;
}

Course *Student::getCourses() {
    return Courses;
}

int Student::operator&lt;(Student &amp;s) {
    int ret = 0;

    int LNRet = strcmp(this-&gt;getLastName(), s.getLastName());
    int FNRet = strcmp(this-&gt;getFirstName(), s.getFirstName());

    if (LNRet &lt; 0) {
        ret = 1;
    } else if (LNRet == 0) {
        if (FNRet &lt; 0) {
            ret = 1;
        }
    }

    return ret;
}

int Student::operator&lt;(const char &amp;s) {
    cout &lt;&lt; "in char *!" &lt;&lt; endl;
    int ret = 0;

    return ret;
}

double Student::getAverage() {
    double total = 0.00;
    for (int i = 0; i &lt; (getCourseCount()); i++) {
        total = total + getMarks()[i];
    }
    return total / getCourseCount();
}
</code></pre>

<p>the main</p>

<pre><code>#include "Course.h"
#include "Student.h"
#include "Node.h"
#include "LinkedList.h"
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;iomanip&gt;
using namespace std;

int main(void) {
    char input[] = "OOP344.dat";
    char output[] = "OUTPUT.txt";
    Student student;
    LinkedList list;
    Node *node;

    // read in file
    ifstream ifile(input, ios::binary);
    while (!ifile.eof()) {
        ifile.read(reinterpret_cast&lt;char *&gt;(&amp;student), sizeof(Student));

        node = new Node(student);
        list.addNode(node);
    }
    ifile.close();

    list.sort();

    // write to file
    ofstream ofile(output);
    if (ofile.is_open()) {

        for (node = list.getFirstNode(); node; node = list.getNextNode(node)) {
            cout &lt;&lt; setw(10) &lt;&lt; "Last Name" &lt;&lt; setw(12) &lt;&lt; "First Name" &lt;&lt; setw(5) &lt;&lt; "Age" &lt;&lt; setw(12) &lt;&lt; "Student ID" &lt;&lt;
                    setw(15) &lt;&lt; "Course"    &lt;&lt; setw(7) &lt;&lt; "Mark" &lt;&lt; endl;
            cout &lt;&lt; setw(10) &lt;&lt; "=========" &lt;&lt; setw(12) &lt;&lt; "==========" &lt;&lt; setw(5) &lt;&lt; "===" &lt;&lt; setw(12) &lt;&lt; "==========" &lt;&lt;
                    setw(15) &lt;&lt; "======"    &lt;&lt; setw(7) &lt;&lt; "=====" &lt;&lt; endl;
            cout &lt;&lt; setw(10) &lt;&lt; node-&gt;getValue().getLastName()
                 &lt;&lt; setw(12) &lt;&lt; node-&gt;getValue().getFirstName()
                 &lt;&lt; setw(5) &lt;&lt; node-&gt;getValue().getAge()
                 &lt;&lt; setw(12) &lt;&lt; node-&gt;getValue().getID()
                 &lt;&lt; setw(22) &lt;&lt; node-&gt;getValue().getAverage()
                 &lt;&lt; endl;

                    int sem, sem_prev;

                    for (int i = 0; i &lt; node-&gt;getValue().getCourseCount(); i++) {
                        sem = (int)node-&gt;getValue().getCourses()[i].Semester;
                        sem_prev = (int)node-&gt;getValue().getCourses()[i-1].Semester;

                        if (!(sem == sem_prev)) {
                            cout &lt;&lt; setw(45) &lt;&lt; "Sem " &lt;&lt; (int)node-&gt;getValue().getCourses()[i].Semester &lt;&lt; ":"
                                 &lt;&lt; setw(7) &lt;&lt; node-&gt;getValue().getCourses()[i].Name
                                 &lt;&lt; setw(7) &lt;&lt; setprecision(4) &lt;&lt; node-&gt;getValue().getMarks()[i] &lt;&lt; endl;
                        } else {
                            cout &lt;&lt; setw(54) &lt;&lt; node-&gt;getValue().getCourses()[i].Name
                                 &lt;&lt; setw(7) &lt;&lt; setprecision(4) &lt;&lt; node-&gt;getValue().getMarks()[i] &lt;&lt; endl;
                        }

                    }

                     cout &lt;&lt; endl;
        }
    }
    ofile.close();

    return (0);
}
</code></pre>

<p>output:</p>

<pre><code>Last Name  First Name  Age  Student ID         Course   Mark
 =========  ==========  ===  ==========         ======  =====
   Sakedad        Roya   25      486503                 74.31
                                         Sem 1: APC100     69
                                                EAC150     92
                                                ICA002     76
                                                IOS110     87
                                                IPC144     99
                                         Sem 2: ULI101     62
                                                DBS201     66
                                                IBC233     94
                                                INT222     58
                                                OOP244     67
                                         Sem 3: DBS301     61
                                                INT322     89
                                                SYS366     52
                                                BAC344     80
                                                OOP344     63
                                         Sem 4: DCN455     74
</code></pre>

<p>the problem is in this line near the bottom. it won't display any decimal points. any help is greatly appreciated.</p>

<pre><code>  setprecision(4) &lt;&lt; node-&gt;getValue().getMarks()[i] 
</code></pre>

<p>i can supply any other files which may be helpful. i'm just hoping my mistakes are somewhere in the main.</p>
