I was just wondering, how to check how many 't's there are in the sentence?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string test = "The man played with the ball in his backyard.";
return 0;
}
I was just wondering, how to check how many 't's there are in the sentence?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string test = "The man played with the ball in his backyard.";
return 0;
}
Jump to Postuse a for loop to iterate through the string and count the number of Ts. You need to count both upper and lower cast Ts.
use a for loop to iterate through the string and count the number of Ts. You need to count both upper and lower cast Ts.
once you do it manually, you'll learn to use the standard algorithm for this std::count(test.begin(),test.end(),'t')
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.