10 per page display

I am working on struct array and the challenge is I have to
Display 10 records at a time. How can I have my program display
10 records at a time and continue from the last record
Displayed to output 10 more records and so on?
@dragonblaze Try just looping through the array and once it's looped 10 times, store the index of where it stopped and then just start at the index you stored for the next 10.
@germanchocolate Thanks for your reply, appreciate it. I am really new in programming, can you please share or show here a basic syntax of how I can loop struct array? Thanks in advance
closed account (N36fSL3A)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
struct Disc
{
    int tracks;
    int current;
};

Disc array[10];

void Display(Disc &disc)
{
    std::cout << "==========\n";
    std::cout << "Tracks   : " << disc.tracks << "\n";
    std::cout << "Current  : " << disc.current << "\n";
    std::cout << "==========\n";
}

int main()
{
    // Initialize arrays... once completed go to for loop
    // Code

    for(int d = 0; d < 10; d++)
    {
        Display(array[d]);
    }
}

Edit to your needs
:)
Last edited on by Fredbill30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void Dump(size_t nStart, size_t nCount)
{
     for (size_t i=nStart; i<(nStart+nCount); i++)
         cout << "Item " << i << std::endl;
}


void SomeFunc()
{
    size_t nIndex = 0;
    size_t nPageSize = 10;

    while (nIndex < 100)
    {
        Dump(nIndex,nPageSize);
        nIndex += nPageSize;
    }
}
Last edited on
using namespace std;

struct perInfo {
char fname [20];
Int age;
};

PerInfo per[100];

int main (){
for (int n = 0; n < 25; n++){
cout << "Enter Name: ";
cin >> per[n].fname;
cout << "Enter Age: ";
cin >> per [n].age;
}

for (int n2 = 0; n2 < 100; n2++){
cout << per[n2].fname << " age is " << per [n2].age;
}
}

This is the code I am working at, I just need to display 10 records or lines per page. Need help on how to do that. Thank you very much for all the replies!
Topic archived. No new replies allowed.