Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to know the number of a certain substring in a string in c++

int nPos = str_to_search.find(str, 0); 
while (nPos != string::npos)
{
	count++;
	nPos = str_to_search.find(str, nPos + str.size());
}
Source by cplusplus.com #
 
PREVIOUS NEXT
Tagged: #number #substring #string
ADD COMMENT
Topic
Name
4+3 =