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

Recommended Answers

All 2 Replies

Line 43. You prompt the user for input, then immediately exit the program. Presumably there should be a cin statement after line 43 and before line 45, then you'll want to do something based on what the user entered.

thank you! I have figured it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.