cwText.h/cpp : Added firstMatchChar(char*,int,char) form of first char. match function.
This commit is contained in:
parent
1ed6202885
commit
638d3e8494
15
cwText.cpp
15
cwText.cpp
@ -158,6 +158,21 @@ char* cw::firstMatchChar( char* s, char c )
|
||||
}
|
||||
|
||||
const char* cw::firstMatchChar( const char* s, char c )
|
||||
{ return firstMatchChar((char*)s,c); }
|
||||
|
||||
char* cw::firstMatchChar( char* s, unsigned n, char c )
|
||||
{
|
||||
if( s == nullptr )
|
||||
return nullptr;
|
||||
|
||||
for(unsigned i=0; *s && i<n; ++s,++i)
|
||||
if(*s == c)
|
||||
return s;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
const char* cw::firstMatchChar( const char* s, unsigned n, char c )
|
||||
{
|
||||
return firstMatchChar((char*)s,c);
|
||||
}
|
||||
|
2
cwText.h
2
cwText.h
@ -67,6 +67,8 @@ namespace cw
|
||||
// if 'c' does not occur in s[]
|
||||
char* firstMatchChar( char* s, char c );
|
||||
const char* firstMatchChar( const char* s, char c );
|
||||
char* firstMatchChar( char* s, unsigned sn, char c );
|
||||
const char* firstMatchChar( const char* s, unsigned sn, char c );
|
||||
|
||||
// Find the last occurrent of 'c' in s[].
|
||||
char* lastMatchChar( char* s, char c );
|
||||
|
Loading…
Reference in New Issue
Block a user