#include <algorithm> // Para std::count_if
#include <cctype> // Para std::isspace
#include <iostream>
int main() {
auto s = std::string{ "25 caracteres sem os espacos." };
auto n = std::count_if( std::begin( s ), std::end( s ), [](char c){ return !std::isspace( c ); } );
std::cout << "String: \"" << s << "\"\n";
std::cout << "Quantidade de caracteres: " << s.size( ) << "\n";
std::cout << "Quantidade de caracteres nao brancos: " << n << std::endl;
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4gLy8gUGFyYSBzdGQ6OmNvdW50X2lmCiNpbmNsdWRlIDxjY3R5cGU+ICAgIC8vIFBhcmEgc3RkOjppc3NwYWNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KCmludCBtYWluKCkgewoJYXV0byBzID0gc3RkOjpzdHJpbmd7ICIyNSBjYXJhY3RlcmVzIHNlbSBvcyBlc3BhY29zLiIgfTsKCWF1dG8gbiA9IHN0ZDo6Y291bnRfaWYoIHN0ZDo6YmVnaW4oIHMgKSwgc3RkOjplbmQoIHMgKSwgW10oY2hhciBjKXsgcmV0dXJuICFzdGQ6Omlzc3BhY2UoIGMgKTsgfSApOwoJCglzdGQ6OmNvdXQgPDwgIlN0cmluZzogXCIiIDw8IHMgPDwgIlwiXG4iOwoJc3RkOjpjb3V0IDw8ICJRdWFudGlkYWRlIGRlIGNhcmFjdGVyZXM6ICIgPDwgcy5zaXplKCApIDw8ICJcbiI7CglzdGQ6OmNvdXQgPDwgIlF1YW50aWRhZGUgZGUgY2FyYWN0ZXJlcyBuYW8gYnJhbmNvczogIiA8PCBuIDw8IHN0ZDo6ZW5kbDsKCXJldHVybiAwOwp9