>Try this, it works
Why do you think I didn't gave him the code?
Anyways, here is my version.
#include <iostream>
#include <string>
#include <cctype>
std::string sentn_case(std::string s)
{
size_t pos=0;
//Capatalize the beigning of the string
while (!isalpha(s[pos])) pos++;
s[pos]=toupper(s[pos]);
//Now find the period and split the string for next recursion
pos=s.find(".");
if (pos==std::string::npos)return s;
while (!isalpha(s[pos])) pos++;
return s.substr(0,pos)+sentn_case(s.substr(pos));
}
int main()
{
std::string s=\
" and then a voice came over.\" hello. how are you. mister\"";
std::cout<<sentn_case(s)<<std::endl;
}
The actual function is just 7 lines!
My solution may be less efficient (considering it uses recursion) but quite elegant.
@ArkM code: The output from your function was: And then a voice came over."hello. How are you. Mister"