#include <iostream>
#include <ctime>
#include <string>
usingnamespace std;
string characterGenPrGood();
void goodGen();
int main()
{
unsigned seed = time(0);
srand(seed);
int choice;
int again = 3;
cout << "Welcome to character generator!" << endl;
do
{
cout << "Type 1 for good character and 2 for a bad character." << endl;
cin >> choice;
while (choice != 1 && choice != 2)
{
cout << "Invalid choice. Enter 1 for good or 2 for bad." << endl;
cin >> choice;
}
if (choice == 1)
goodGen();
}while(again != 1);
cout << "Good luck with your story! Glad I could help!";
return 0;}
string characterGenPrGood()
{
constint SIZE = 11;
string adjective[SIZE] = {"affectionate","debonair", "dependable", "faithful", "generous", "kind", "self-disciplined", "Warmhearted", "thoughtful", "patient", "sensible"};
int choice = rand() %10 + 0;
string adjchoice = adjective[choice];
return adjchoice;
}
void goodGen()
{
cout << "You chose good." << endl;
bool gender;
gender = rand() %1 + 0;
if (gender= true)
cout << "The character is a girl." << endl << "THe character is ";
else
cout << "The character is a boy." << endl << " The character is ";
for(int i = 0; i < 2; i++)
{
cout << " " << characterGenPrGood() << " " << characterGenPrGood << endl;
}
}
Make the compiler work for you, I used cpp.sh (the gear icon top right of the code), with all 3 warnings on:
In function 'void goodGen()':
81:19: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
92:49: warning: the address of 'std::string characterGenPrGood()' will always evaluate as 'true' [-Waddress]
Thanks a lot! I appreciate it. Dunno why I didn't look at the compiler. Did this for fun to brush up on what I learned in C++ before I take java next semester. I appreciate it!