Thread: paginate
View Single Post
  #1 (permalink)  
Old February 3rd, 2006, 10:49 AM
Neeko Neeko is offline
Authorized User
 
Join Date: Dec 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default paginate

hi,
i was wondering if any could help me with my coding, i have hit a dead end at trying to make a code to paginate the output of the given data

I am trying to write an additional function displayReport2() which will produce a similar report to the given displayReport() but will 'paginate' the output into blocks of 10 students.

Each block will have a header giving the titles of columns (RegNo,Name). There should be a space of 2 lines before the end of a block and the header of the next block.

This is what i have done so far...

code:

#include <iostream>
using namespace std;

const int MAX_CLASS_SIZE = 500;
const int MAX_SURNAME_SIZE = 20;
const int MAX_FNAME_SIZE = 40;

struct Student {
    char id[10];
    char surname[MAX_SURNAME_SIZE];
    char firstname[MAX_FNAME_SIZE];
};

typedef Student StudentGroup[];

void getStudent(Student& s);

void displayStudent(Student s);

void getData(StudentGroup arr, int& howMany);

void bubSort(StudentGroup arr, int howMany);

void displayReport(StudentGroup arr, int howMany);

void displayReport2(StudentGroup arr, int howMany);

int main()
{
    Student s[MAX_CLASS_SIZE];
    int n = 0;

    getData(s,n);
    bubSort(s,n);
    displayReport2(s,n);
}

void getStudent(Student& s)
{
    cin >> s.id ;
    cin >> s.surname;
    cin.get(); // gets rid of next char (a tab)
    cin.getline(s.firstname, MAX_FNAME_SIZE); // collects rest of input line
}

void displayStudent(Student s)
{
    cout << s.id << " " << s.firstname << ' ' << s.surname;
    // this was screwed up because I had ' ' instead of " "
}

void getData(StudentGroup arr, int& howMany)
{
    howMany = 0;
    while (cin)
    {
        getStudent(arr[howMany]);
        if(cin) // successful data read of 1 student
        {
            howMany++;
        }
    }
}


void bubSort(StudentGroup arr, int n)
{
}

void displayReport(StudentGroup arr, int howMany)
{
    for (int i=0; i<howMany; i++)
    {
        displayStudent(arr[i]);
        cout << endl;
    }
    cerr << "Finshed writing report\n";
}

void displayReport2()
{

}

.
Any help would be much appreciated.
Thank you for your time.
Regards.
Nick

Reply With Quote