#include<iostream>
#include<ctime>
usingnamespace std;
int divide ()
{
int choice;
cout<<"Please choose which game you would like to play:\n"
<<"1 High low\n"
<<"2 Roulette\n"
<<"3 Blackjack\n"
<<"4 Slots\n"
<<"5 I want to leave";
cin>>choice;
return(choice);
}
int highlow ()
{
int a = 4;
cout<<a;
return (a);
}
int roulette ()
{
cout<<"roulette";
return(2);
}
int blackjack ()
{
cout<<"blackjack";
return(3);
}
int slots()
{
cout<<"slots";
return(4);
}
int main()
{
//money player has
srand((unsigned)time(0));
int randa = 100;
int randb = 100;
int money = rand()%randb+randa;
cout<<"Welcome to the Eiselen Casino!\n\nYou have $"<<money<<" to gamble with.\n\nYou can play High-Low, Roulette, Blackjack, or Slots. You may play for how ever long you would like as long as you do not bust. \nGood luck!\n\n";
divide();
if (divide = 1) {int highlow();}
elseif (divide = 2) {int roulette();}
elseif (divide = 3) {int blackjack();}
elseif (divide = 4) {int slots();}
system("PAUSE");
return 0;
}
The last few sets of lines are where the problem is. I don't know why, because divide() returns either 1-4, which is the problem I'm looking at right now - this isn't a finished code at all.
I only have it so if I enter it so that divide would returns '1', it should work, but these if statements aren't functioning for some reason..?
In your if statements you are assigning divide (which is a function) the values 1-4. On line 57 you aren't assigning the return value of divide() to anything. What I think you need to do (because I'm not sure what the aim of your program is) change line 57 to something line int d = divide(); and your if statements need to check the value of that using == not =.
The bodies of your if statements (int highlow(); // etc ) aren't actually doing anything (and don't make sense) either.
You also don't need to enclose the return value in brackets in your functions (although it makes no difference).