TF++, Miscellaneous classes and modules in C++:

◆ count_char()

int tfxx::string::count_char ( const std::string &  s,
const char &  c 
)

count characters in string

Parameters
sstring to look for c
ccharacter to find in string
Returns
number of c characters in string

count characters in string

Parameters
sstring to look for c (substring is stripped from this)
ccharacter to find in string
Returns
number of c characters in string

Definition at line 142 of file stringfunc.cc.

143  {
144  int result=0;
145  for (std::string::const_iterator i=s.begin(); i!=s.end(); i++)
146  { if (*i == c) { result++; } }
147  return(result);
148  }