//Mad lib
// Creates a story based upon user input 

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

string askText(string prompt);
int askNumber(string prompt);
void tellStory(string name, string noun, int number, string bodyPart,string verb);


int main()
{
    cout << "Welcome to Mad Lib.\n\n";
    cout << "Awnser the following questions to help create a new story. \n";

    string name = askText("Please enter a name: ");
    string noun = askText("Please enter a plural noun: ");
    int number = askNumber("Please enter a number: ");
    string bodyPart = askText("Please enter a body part: ");
    string verb = askText("Please enter a verb ");
    tellStory(name , noun , number , bodyPart , verb);
    system("PAUSE");
    return 0;
}

string askText(string prompt) 
{
       string text;
       cout << prompt;
       cin >> text;
       return text;
}

void tellStory(string name, string noun, int number, string bodyPart, string verb)
{
               cout << "\nHere's your story:\n";
               cout << "The famous explorer ";
               cout << name;
               cout << " had nearly given up a life-long quest to find\n";
               cout << "The Lost City of ";
               cout << noun;
               cout << " when one day, the ";
               cout << noun;
               cout << " found the explorer .\n";
               cout << "Surrounded by ";
               cout << number;
               cout << "" << noun;
               cout << ", a tear came to ";
               cout << name << "'s ";
               cout << bodyPart << ".\n";
               cout << "After all this time, the quest was finally over. ";
               cout << "And then, the ";
               cout << noun << "\n";
               cout << "promply devoured ";
               cout << name << ".";
               cout << "Moral of the story? Be careful what you ";
               cout << verb;
               cout << " for.";
}

Recommended Answers

All 4 Replies

I see a definition for tellStory and askText but not for askNumber. Just define the funciton (like you did for the other two) and the compiler will be happy.

Isnt the definition tellstory right here: string askText(string prompt); int askNumber(string prompt); void tellStory(string name, string noun, int number, string bodyPart,string verb); (Lines 10,11,12)

You were asking about askNumber, not tellStory.

What you point out are the declarations not the definitions. Declarations give the signature of the function (parameters, return type) and definitions provide the functional body for the function. Lines 30 and 38 start the definitions of askText and tellStory, respectively.

Ah! I see thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.