home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
chrcount.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-21
|
733b
|
33 lines
/*********
* Function: CHRCOUNT
* By: Tom Rettig
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* Syntax: CHRCOUNT( <char>, <expC> )
* Return: <expN> times <char> appears in <expC>
* Note : <char> is <expC>.
* If LEN(<char>) is greater than 1, only first char is looked at.
* Is case sensitive.
********/
#include "trlib.h"
TRTYPE chrcount()
{
char *chr, *instr;
int ret;
if ( PCOUNT==2 && ISCHAR(1) && ISCHAR(2) )
{
chr = _parc(1);
instr = _parc(2);
for ( ret=0; *instr; instr++ )
{
if ( *chr == *instr )
ret++;
}
_retni( ret );
}
else
_retni(ERRORNEG); /* error -1 */
}