I had to use && instead of ||.
do {
cin>> viewInstructions;
cin.ignore();
switch(toupper(viewInstructions)) {
case 'Y':
cout<<...
Type: Posts; User: wipeout4wh
I had to use && instead of ||.
do {
cin>> viewInstructions;
cin.ignore();
switch(toupper(viewInstructions)) {
case 'Y':
cout<<...
Why should I avoid static and global variables? Isn't it kind of necessary to use them sometimes?
I did manage to fix my do/while loop before you posted that, but I didn't mention it.
do {
...
Yeah... I didn't really understand that.
So shuffleDeck() should use deck as a parameter? I made deck a global variable, so shuffleDeck() can access it even if it's not a parameter. Do I still...
I've learned a little about pointers, but I still don't completely understand why they are useful. I'll change my shuffling function to loop 52 times instead of 500. The code I posted only loops 100...
The index is just the part of an array that's in square brackets, right?
If I do that, it would still reuse the cards that are still in play when I reshuffle the deck. If I have a 5 in my hand,...
How would it eliminate the need to repopulate the array? I would have to send the cards that are no longer in play to a discard pile array, then bring them back to the deck when it's reshuffled.
...
I guess, but drawing a random card is easier, and it accomplishes the same task in the long run. Is there really any benefit besides making the game's programming more realistic?
I don't know anything about pointers yet, so I don't know what any of that means. I still don't see why shuffling is necessary, either.
But that still doesn't solve the problem of getting a new, partially full deck (not including the cards that are in play) when every card is gone. Drawing a random card is pretty much the equivalent...
So there's no way to reset the deck? How would I make it possible to continue playing after the deck runs out of cards, and prevent the infinite loop?
Sorry if this is off-topic, but is there a way to efficiently check the sum of each value in an array without manually adding deck[1] + deck[2] + deck[3] etc., and a way to force a static variable to...
I didn't use that before because I didn't know what static was. I just looked it up and did it, and you're both right. It compiles without any warnings now, and it doesn't repeat any cards. Thanks...
This is the full code:
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
int drawCard();
It compiles in Code::Blocks with one warning.
C:\Documents and Settings\David\My Documents\Programming\Blackjack\main.cpp|28|warning: extended initializer lists only available with -std=c++0x or...
Leaving both int and [52] out works, leaving this:
while (loop != 0) {
deck =...
while (loop != 0) {
deck[52] = {1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13};
loop = 0;
}
Would...
Thanks. I have the do... while loop and the temporary variable done. The return is at the end, and it's at least choosing cards now. I put the time stuff and srand(now) in main(), but now it's...
The last line is supposed to remove the drawn card from the deck (by setting its value to 0), so it should remember the current state AFAIK. Since the while loop that initiates the array sets loop to...
I'm writing a simple Blackjack game, but I'm having a problem. This is my code so far:
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
int...
What do you mean by "the right type"?
On line 6 ("{") I get: number of arguments doesn't match prototype.
On line 1040 (Which doesn't exist...) I get: prototype declaration.
What arguments do I need to use?
I did that, now I get an error on "{".
That doesn't help...
The program only runs for a few seconds, so I really don't see a reason to click the minimize button. I want it to run minimized from the beginning so I never have to see it....
Is there a way to make a program run minimized? I know you can just make a shortcut that runs minimize, but how can I do it without a shortcut?
Ok, I figured out how to make it restart without a loop. I'm done with the game now, but how can I assign an icon to the .exe?