Determine if the supplied sub-string is contained within the supplied string on a case-sensitive basis
| Return Type | Function name | Arguments |
|---|---|---|
| int32_t | CstrFirstI | (const char*,const char*,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
int32_t CstrFirstI (const char* cpHaystack)const char* cpNeedle,
{
// Category: Text Processing
//
// Determine if the supplied sub-string is contained within the supplied string on a case-sensitive basis
//
// Arguments: 1) cpHaystack The source string
// 2) cpNeedle The string being sought
//
// Returns: Position If the sub-string occurs in the string
// 0 Otherwise
uint32_t n ; // String iterator (position)
char lower ; // Lower case of first char of needle
char upper ; // Upper case of first char of needle
if (!cpHaystack || !cpHaystack[0]|| !cpNeedle || !cpNeedle[0])
return false ;
lower = tolower(cpNeedle[0]);
upper = toupper(cpNeedle[0]);
for (n = 0; cpHaystack[n] ; n++)
{
if (cpHaystack[n] != lower && cpHaystack[n] != upper)
continue ;
if (!CstrCompareI(cpHaystack + n, cpNeedle))
return n ;
}
return -1;
}