Question: Really have no idea why my code keeps failing on the 1 st part. * See picture * 1 :Calling the three unit test written
Really have no idea why my code keeps failing on the st part. See picture
:Calling the three unit test written by you.
Calling bool test; that was written by you to test your implementation of the myMadLib function.
Compilation failed
Compilation failed
myMadLib.cpp: In function 'int testpassedstd::ofstreamd:
myMadLib.cpp::: error: 'test was not declared in this scope
bool result test;
myMadLib.cpp::: error: 'test was not declared in this scope
result test;
myMadLib.cpp::: error: 'test was not declared in this scope
result test;
My code
#include
#include
#include
Function to check if a string is empty or contains only whitespace characters
bool isWhitespaceconst std::string& str
for char c : str
if isspacec
return false;
return true;
Function to generate a funny short story using provided inputs
std::string myMadLibconst std::string& firstName, const std::string& placeName, int number, const std::string& pluralNoun
Check if any of the input strings is empty or contains only whitespace
if isWhitespacefirstName isWhitespaceplaceName isWhitespacepluralNoun
std::cerr "Error: Empty or whitespaceonly input detected
;
return ;
Construct the funny short story
std::ostringstream oss;
oss firstName went to placeName to buy number different types of pluralNoun ;
return oss.str;
int main
Read inputs from standard input cin
std::string firstName, placeName, pluralNoun;
int number;
std::cout "Enter first name: ;
std::getlinestd::cin, firstName;
std::cout "Enter place name: ;
std::getlinestd::cin, placeName;
std::cout "Enter a whole number: ;
std::cin number;
std::cout "Enter a plural noun: ;
std::cin.ignore; Ignore the newline character left in the input buffer
std::getlinestd::cin, pluralNoun;
Generate the funny short story
std::string story myMadLibfirstName placeName, number, pluralNoun;
Print the story
if story.empty
std::cout "Funny short story:
story std::endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
