Determine if the supplied sub-string is contained within the supplied string on a case-sensitive basis
| Return Type | Function name | Arguments |
|---|---|---|
| int32_t | CstrFirst | (const char*,const char*,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
int32_t CstrFirst (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)
if (!cpHaystack || !cpHaystack[0]|| !cpNeedle || !cpNeedle[0])
return false ;
for (n = 0; cpHaystack[n] ; n++)
{
if (cpHaystack[n] != cpNeedle[0])
continue ;
if (!CstrCompare(cpHaystack + n, cpNeedle))
return n ;
}
return -1;
}