topical media & game development
professional-program-22-FunctionObjects-EmptyString.c
? /
professional-program-22-FunctionObjects-EmptyString.c
include <functional>
include <algorithm>
include <string>
include <vector>
include <iostream>
using namespace std;
void findEmptyString(const vector<string>& strings)
{
vector<string>::const_iterator it = find_if(strings.begin(), strings.end(),
mem_fun_ref(&string::empty));
if (it == strings.end()) {
cout << "No empty strings!\n";
} else {
cout << "Empty string at position: " << it - strings.begin() << endl;
}
}
int main(int argc, char** argv)
{
vector<string> myVector;
string one = "blah";
string two = "";
myVector.push_back(one);
myVector.push_back(one);
myVector.push_back(two);
myVector.push_back(one);
findEmptyString(myVector);
return (0);
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.