M
Mike Copeland
I am trying to print/display a list of strings in 2 columns. My
attempt to use 2 iterators (one for the first half of the list and
another for the 2nd half) doesn't compile - and I can't establish the
starting point of the 2nd iterator.
Note that I'm not dealing with an odd set of data, nor am I handling
the end of each subset of the list's data (not sure how best to do that,
either).
Perhaps this approach is entirely wrong, but it's the best I can come
up with. Any thoughts? TIA
size_t ppp = 0;
string str1, str2;
list<string> sList;
list<string>::iterator it1;
list<string>::iterator it2;
// populate list with some data...
ppp=sList.size();
sList.sort(), ii = 3;
it2 = sList.begin()+(ppp/2); // compiler won't allow!
for(it1 = sList.begin(); it1 != sList.end(); it1++)
{
str1 = *it1; // left side
str2 = *it2; // right side
// format and print a line
} // for
attempt to use 2 iterators (one for the first half of the list and
another for the 2nd half) doesn't compile - and I can't establish the
starting point of the 2nd iterator.
Note that I'm not dealing with an odd set of data, nor am I handling
the end of each subset of the list's data (not sure how best to do that,
either).
Perhaps this approach is entirely wrong, but it's the best I can come
up with. Any thoughts? TIA
size_t ppp = 0;
string str1, str2;
list<string> sList;
list<string>::iterator it1;
list<string>::iterator it2;
// populate list with some data...
ppp=sList.size();
sList.sort(), ii = 3;
it2 = sList.begin()+(ppp/2); // compiler won't allow!
for(it1 = sList.begin(); it1 != sList.end(); it1++)
{
str1 = *it1; // left side
str2 = *it2; // right side
// format and print a line
} // for