
Naeem F. answered 07/06/21
Senior Software Engineer with 30+ years of experience
std::string ParseStr(const std::string& str)
{
if((str.size() > 3) && (str.at(3) == ' '))
{
return "Good";
}
return "Bad";
}
Kat H.
asked 07/06/21C++. Define a function ParseStr() that takes a string parameter and returns "Good" if the character at index 3 in the string parameter is a space. Otherwise, the function returns "Bad".
Ex: ParseStr("cheetah") returns
Bad
Recall string's at() returns a character at the specified position in the string. Ex: myString.at(3)
Code:
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
/* Your code goes here */
int main() {
string input;
string output;
getline(cin, input);
output = ParseStr(input);
cout << output << endl;
return 0;
}
Naeem F. answered 07/06/21
Senior Software Engineer with 30+ years of experience
std::string ParseStr(const std::string& str)
{
if((str.size() > 3) && (str.at(3) == ' '))
{
return "Good";
}
return "Bad";
}
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.