A few basic STL Problems
| Oubliez (2) | |||
| Hi everyone. I'm working on an assignment for my CS class and I'm having a few issues coming up with how to do my few remaining problems. The assignment specifies that we may not use recursion, loops, or switch statements; only the STL. Any help or hints would be greatly appreciated as I'm out of ideas on how to get the methods to work. 1. Find the total length of all strings in a set. The assignment suggests using the accumulate algorithm. Here's what I have so far:
2. Determine the number of lines in a file. The assignment suggests using the count algorithm and istreambuf_iterator<char>. Unfortunately I'm not even sure where to begin with this one, I guess I'm not sure how the istreambuf_iterator works and how to use it. Thanks for any help that anyone is willing to give. | |||
| jsmith (400) | |||
| For the first problem, check out http://www.sgi.com/tech/stl/accumulate.html For the second problem, check out http://www.sgi.com/tech/stl/istream_iterator.html Especially look at the examples. They are close to what you need. | |||
| Oubliez (2) | |||
| Thanks, that helped tremendously. | |||
This topic is archived - New replies not allowed.
