#include<iostream>
#include<string>
size_t count_spaces(std::string& str)
{
size_t spaces=0;
for(size_t i=0; i<str.size(); ++i)
if( str[i]==32 )
++spaces;
return( spaces );
}
int main()
{
std::string str("This is a string with some spaces.");
size_t spaces = count_spaces(str);
std::cout<<"The string ""<<str.c_str()<<"" has "<<spaces<<" spaces.\n"<<std::endl;
}
.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
This is not a question.
what is string
i dont no string for servlate
.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......
Read the characters one at a time, and write an "if" for each of the cases. In each case, if the condition is fulfilled, increment the corresponding counter variable.
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
This is not a question.
what is string
Use text-editor notepad++
i dont no string for servlate
This is an assignment not a question.
i am sam
what is if(!(str[i]==32))
what is if(!(str[i]==32))
[ string toupper $str ] or [ string tolower $str ]