I'm having troubles getting this program to work. Yes i know its stupid and immature but hey at least its original. All seems to work fine until it tries to use the program play(). it outputs "Time to play :Dplay_balls". Someone please help me im new to c++. and I'm not sure if passing strings through functions is legal but couldnt find any help anywhere else. I'm on linux using KDevelop. (Any suggestions for a better linux compiler, i was using dev c++ on windows)
Code:
/***************************************************************************
Name: Balls
Copyright: Charles Ewert
Author: Charles J. Ewert
Date: 06/09/04 23:29
Description: A wonderful text-based console "game" about balls.
*Intended to get familiar with functions*
***************************************************************************/
#include <iostream>
#include <string>
using namespace std;
string play (string c_balls);
float n_balls;
string color = "";
string c_balls = "";
string balls = "";
int main()
{
cout << "You are in a dark room and you stumble upon some balls.\n"
<< "Play with balls?(Y/N)";
cin >> balls;
if (balls == "Y" || balls == "y")
{
cout << "\nGood choice.\n"
<< "How many balls did you feel?";
cin >> n_balls;
cout << "\nVery hot.\n"
<< "What color were they? (W)hite or (B)lack";
cin >> c_balls;
cout << "\n\nTime to play :D\n"
<< play(c_balls)
<< n_balls << " " << color << " ."
<< "\nCongrats! Thanks for playing skank";
}
else
{
cout << "Everyone loves balls!!\n"
<< "Go home... Game Over";
return 0;
}
}
string play(string c_balls)
{
if (c_balls == "B" || c_balls == "b")
{
color = "black";
}
else
{
color = "white";
}
return "Even though it was dark you managed to fondle " ;
}