Here is a string version for fun...
Code:
#include <iostream>
#include <string>
void StrTrim(std::string& buffer, const std::string& trimChars)
{
std::string::size_type first = buffer.find_first_not_of(trimChars);
std::string::size_type last = buffer.find_last_not_of(trimChars);
if (first == std::string::npos)
buffer.clear();
else if (first <= last)
buffer = buffer.substr(first, (last+1)-first);
}
int main()
{
std::string buffer("_!ABCDEFG#");
std::string trim("#A!_\0");
std::cout << "The string before calling StrTrim: ";
std::cout << buffer;
std::cout << "\n";
StrTrim(buffer, trim);
std::cout << "The string after calling StrTrim: ";
std::cout << buffer;
std::cout << "\n";
}
Edit: Since you are using C style strings that won't work as is (although it would be close). Do you have publib.h on your system? If you open it, is there a declaration for strtrim in there?