Count the incidence of a particular char in a source string
| Return Type | Function name | Arguments |
|---|---|---|
| uint32_t | CstrIncidence | (const char*,char,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
uint32_t CstrIncidence (const char* str)char c,
{
// Category: Text Processing
//
// Count the incidence of a particular char in a source string
//
// Arguments: 1) cpStr The source string
// 2) c The char value being counted
//
// Returns: 0+ Being the number of times the supplied test char occurs within the supplied cstr
const char* i ; // Input string iterator
uint32_t n = 0; // Incidence counter
if (!str || !str[0]|| !c)
return 0;
for (i = str ; *i ; i++)
{
if (*i == c)
n++ ;
}
return n ;
}