Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 3rd, 2006, 10:49 AM
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
  #2 (permalink)  
Old March 8th, 2006, 03:33 PM
Authorized User
 
Join Date: Oct 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to C@uark
Default

void displayStudent(Student s)
{
    cout << s.id << " " << s.firstname <<" "<< s.surname;

}

your cout statement had single quotes in it and should have double quotes as in the above. double quotes represent strings terminated by a null character as where single quotes represent a single character not terminated by a null character
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Paginate function with thumbnails dragon_rouge BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 March 13th, 2008 07:52 PM
Paginate function with thumbnails, chpter 7 and 16 dragon_rouge Beginning PHP 0 March 10th, 2008 06:26 AM
Paginate xml data solos Classic ASP XML 0 April 4th, 2007 01:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.