MadLib Needs Help

I was putting together my MadLib but my professor gave little to no instruction on how to do so and for some reason the file isn't compiling or running correctly




// Hmwrk02
// This program outputs a Mad Lib using variables input by computer.

#include <iostream>
#include <string>
using namespace std;

int main (void)
{
//// 1.0 Main ////

//// 1.1 User Instructions ////
cout << "Enter words as prompted" << endl;
cout << "If more than one word is needed, sepereate using space" << endl;
cout << endl;
cin.ignore(999,'\n');


//// 1.2 Prompt User ////

//// 1.2.1 Verbs ////
string verb1, verb2;
cout << "Enter TWO verbs: ";
cin >> verb1;
cin >> verb2;


//// 1.2.2 Nouns ////
string noun1, noun2, noun3, noun4, noun5, noun6;
cout << "Enter SIX nouns: ";
cin >> noun1;
cin >> noun2;
cin >> noun3;
cin >> noun4;
cin >> noun5;
cin >> noun6;


//// 1.2.3 Animal ////
string animal;
cout << "Enter ONE animal: ";
cin>> animal;


//// 1.2.4 Careers ////
string career1, career2, career3, career4;
cout << "Enter FOUR careers: ";
cin >> career1;
cin >> career2;
cin >> career3;
cin >> career4;


//// 1.2.5 Adjective ////
string adjective;
cout << "Enter ONE adjective: ";
cin >> adjective;



//// 1.3 Mad Lib ////
cout << "We don't " << verb1 << "and" << verb2 << noun1 << "because it's cute." << endl;
cout << "We " << verb1 << "and" << verb2 << noun1 << "beacuse we are members of the " << animal << "race." << endl;
cout << " And the " << animal << "race is filled with " << noun2 << "." << endl;
cout << "And " << career1 << "," << career2 << "," << career3 << "," << career4 << ","
<<"These are " << adjective << "pursuits and necessary to sustain " << noun3 << "." << endl;
cout << "But " << noun1 << ", " << noun4 << "," << noun5 << "," << noun6 << ", these are what we stay alive for." << endl;



//// 3.0 Endgame ///

//// 3.1 Pause Screen ///
cout << endl;
cout << "Press ENTER to continue..." << endl;
cin.ignore(999, '\n');

//// 3.2 Terminate Program ////
return 0;
}
If you are using visual studio do

#include "stdfax.h"

this might be a software error because on my IDE it seems to work fine, just add some spacing between the words.

You are doing great otherwise
Last edited on
i'm using visual studios so would stdfax.h work on there as well or would i have to find something else to use?
Since you are using visual studio add
 
#include "stdfax.h" 

at the top of your program and that should fix it

with all of your visual studio programs you want to do this or it wont work and the compiler will have and error
Last edited on
You can go to your project settings and turn off "Precompiled Headers" or something to allow to you remove it. (I would highly suggest doing so).

You can also simply use an Empty Project to avoid VS adding any weird stuff to it.
I know you made several spelling mistakes but that doesn't matter (to the program) the only thing that i can think of is the program closes before you are able to read it, in which you will have to type system("pause"); but don't use this in advance classes or in the real world because this can lead to security issues. if this isnt the problem please be more specific.
You guys should really stop giving bad advice to someone who is completely new, and actually has an assignment that looks the exact same as the one I had back when I took my first class in programming.

You're missing the last curly brace to close out your int main body.

Also correct me if I'm wrong on this, but is your professor's name Hester by any chance?
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Hmwrk02
// This program outputs a Mad Lib using variables input by computer.

#include <iostream>
#include <string>
using namespace std;

int main (void)
{
//// 1.0 Main ////

//// 1.1 User Instructions ////
cout << "Enter words as prompted" << endl;
cout << "If more than one word is needed, sepereate using space" << endl;
cout << endl;
cin.ignore(999,'\n');


//// 1.2 Prompt User ////

//// 1.2.1 Verbs ////
string verb1, verb2;
cout << "Enter TWO verbs: ";
cin >> verb1;
cin >> verb2;


//// 1.2.2 Nouns ////
string noun1, noun2, noun3, noun4, noun5, noun6;
cout << "Enter SIX nouns: ";
cin >> noun1;
cin >> noun2;
cin >> noun3;
cin >> noun4;
cin >> noun5;
cin >> noun6;


//// 1.2.3 Animal ////
string animal;
cout << "Enter ONE animal: ";
cin>> animal;


//// 1.2.4 Careers ////
string career1, career2, career3, career4;
cout << "Enter FOUR careers: ";
cin >> career1;
cin >> career2;
cin >> career3;
cin >> career4;


//// 1.2.5 Adjective ////
string adjective;
cout << "Enter ONE adjective: ";
cin >> adjective;



//// 1.3 Mad Lib ////
cout << "We don't " << verb1 << "and" << verb2 << noun1 << "because it's cute." << endl;
cout << "We " << verb1 << "and" << verb2 << noun1 << "beacuse we are members of the " << animal << "race." << endl;
cout << " And the " << animal << "race is filled with " << noun2 << "." << endl;
cout << "And " << career1 << "," << career2 << "," << career3 << "," << career4 << ","
<<"These are " << adjective << "pursuits and necessary to sustain " << noun3 << "." << endl;
cout << "But " << noun1 << ", " << noun4 << "," << noun5 << "," << noun6 << ", these are what we stay alive for." << endl;



//// 3.0 Endgame ///

//// 3.1 Pause Screen ///
cout << endl;
cout << "Press ENTER to continue..." << endl;
cin.ignore(999, '\n');

//// 3.2 Terminate Program ////
return 0;
} 


It runs OK - need a bit of a tidy up with output, spaces etc.
Last edited on
Topic archived. No new replies allowed.