how to count all spaces in java string code example
Example: count spaces in string java
/* let string is s*/
void countSpace(std::string s)
{
int len=s.size(); int c=0;
for(int i=0;i<len;i++)
if(s[i]==' ') c++;
cout<<"Total Number of spae in give string is "<<c;
}
/**************************************************************************
If the user already know the total number of words that string have
then total_number_of_space_in_string = total_number_of_words_in_string - 1;
***************************************************************************/