how do I print a vector in increments of 7?

I am trying to print out a vector in increments of 7 following a string pattern match.
I am able to print out the first set of 7, but unable to print out the following 3 sets.

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
    char *data()
    {
            char buff[BUFSIZ];
            FILE *fp = stdout;
            char * cstr = buff;
            vector<std::string> vrecords;
            while(std::fgets(buff, sizeof buff, fp) != NULL){
                    //get rid of null termination from fgets
                    size_t n = std::strlen( buff );
                    if ( n && buff[n-1] == '\n' ) buff[n-1] = '\0';
                    //push everything into vector
                    if ( buff[0] != '\0' ) vrecords.push_back( buff );
            }
            for(int t = 0; t < 7; ++t){
                    auto vecbuy = std::find( vrecords.begin(), vrecords.end(), "Buy" );
                    auto vecsell = std::find( vrecords.begin(), vrecords.end(), "Sell" );
                    if ( vecbuy != vrecords.end() ){
                            cout << vrecords[t] << " " << endl;
                            //cout << "found buy" << endl;
                    }
                    if ( vecsell != vrecords.end() ){
                            cout << "found sell" << endl;
                    }
                    cout << vrecords[t] << " " << endl;
            }
    }


existing output:

./control.o
198397652
2014-11-14 15:10:10
Buy
0.00517290
0.00100000
0.00100000
0.00000517

expected output:

198397652
2014-11-14 15:10:10
Buy
0.00517290
0.00100000
0.00100000
0.00000517
198397685
2014-11-14 15:10:13
Buy
0.00517290
0.00100000
0.00100000
0.00000517
198398295
2014-11-14 15:11:14
Buy
0.00517290
0.00100000
0.00100000
0.00000517
203440061
2014-11-21 16:13:13
Sell
0.00825550
0.00100000
0.00100000
0.00000826
Last edited on
Topic archived. No new replies allowed.