Answers for "count spaces in string java"

C++
0

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;
***************************************************************************/
Posted by: Guest on April-10-2021

Browse Popular Code Answers by Language