#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
#define HIGH 11
#define LOW 1
int playfirst;
int playsecond;
int temp;
time_t seconds;
void deal (bool faceup) //deal function
{
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
temp = rand() % (HIGH - LOW + 1) + LOW;
if (faceup == true)
if (temp != 11)
cout << temp << endl;
else
cout << "Ace" << endl;
else
cout << "Unkown card \n";
}
int main ()
{
cout << "Blackjack Program \n";
cout << endl << "Your cards" << endl;
time(&seconds);
srand((unsigned int) seconds);
deal (true); //Deals your first card
time(&seconds);
srand((unsigned int) seconds);
playfirst = temp;
deal (true); //deals your second card
playsecond = temp;
cout << "Hit (H) or Stand (S)?" << endl;
return (0);
}
need help with a simple blackjack program
Page 1 of 13 Replies - 1083 Views - Last Post: 01 October 2010 - 10:46 AM
#1
need help with a simple blackjack program
Posted 21 September 2010 - 02:17 PM
hey guys, i am to program a simple blackjack program that generates two random cards for the user and ask if the user wants to stay or hit it. so far, when i tried to compile the program, nothing showed up and showed me this message: "The program '[492] alt.exe: Native' has exited with code 0 (0x0)."
Replies To: need help with a simple blackjack program
#2
Re: need help with a simple blackjack program
Posted 21 September 2010 - 02:34 PM
Congratulations, it compiled and ran!
Now you need to find your output. If you're using XCode, look for the console. You might use break points to force it to appear. Visual Studio has something similar, but I don't remember what it's called.
Now you need to find your output. If you're using XCode, look for the console. You might use break points to force it to appear. Visual Studio has something similar, but I don't remember what it's called.
#3
Re: need help with a simple blackjack program
Posted 21 September 2010 - 03:34 PM
It compiles fine for me but at line 44
You prompt the user for input, then immediately exit the program
cout << "Hit (H) or Stand (S)?" << endl;
You prompt the user for input, then immediately exit the program
#4
Re: need help with a simple blackjack program
Posted 01 October 2010 - 10:46 AM
thank you! i have figured it out. I was missing a cin statement XP
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|