2.2.3.15.15 string::GetNumTokens

Description

Return the number of tokens in this string where a token is separated by the delimiter specified by chDelimiter.

Syntax

int GetNumTokens( char chDelimiter = 0 )

Parameters

chDelimiter
[input]A character representing the delimiter.

Return

The number of tokens in this string.

Examples

EX1

void string_GetNumTokens_ex1()
{
	string str1("apples peaches pumpkins");
	int nRet = str1.GetNumTokens(); //default chDelimiter is whitespace
	out_int("", nRet);//3
	
	string str2("apples,peaches,pumpkins");
	nRet = str2.GetNumTokens(',');
	out_int("", nRet);//3	
}

Remark

This member function returns the number of tokens in this string where a token is separated by the delimiter specified by chDelimiter. Default is 0 (null constant) so chDelimiter does not have to be specified when any white space (space, tab, newline, etc.) is to be used as the delimiter.

See Also

string::GetToken, string::GetTokens

Header to Include

origin.h