3 Replies - 1487 Views - Last Post: 01 October 2010 - 10:46 AM Rate Topic: -----

#1 xiansen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 26-August 10

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)."

#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);
}


Is This A Good Question/Topic? 0
  • +

Replies To: need help with a simple blackjack program

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

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.
Was This Post Helpful? 0
  • +
  • -

#3 Ollie9  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 91
  • Joined: 10-May 10

Re: need help with a simple blackjack program

Posted 21 September 2010 - 03:34 PM

It compiles fine for me but at line 44

	    cout << "Hit (H) or Stand (S)?" << endl;



You prompt the user for input, then immediately exit the program
Was This Post Helpful? 0
  • +
  • -

#4 xiansen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 26-August 10

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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1