Hey guys, im new to the forums and really need help with this program. It's worth 35 points for my programming class and I'm freaking out. I keep getting error C2784. Here's the code and I appreciate all your help:

#include <iostream>
#include <string>
#include <ctime>
using namespace std ;

const int NUMBEROFCARDS = 52;
int HeartsCount = 0;
int ClubsCount = 0;
int SpadesCount = 0;
int DiamondsCount = 0;
int CardDrawCount = 0;
int SuitCount = 0;

// Shuffle the elements in an array
void Shuffle(int List[], int Size)
{
  srand(time(0));
  for (int I = 0; I < Size; I++)
  {
    // Generate an index randomly
    int Index = rand() % NUMBEROFCARDS;
    int Temp = List[I];
    List[I] = List[Index];
    List[Index] = Temp;
  }
}

int main()
{
  int Deck[NUMBEROFCARDS];
  const string Suits[] = {"Clubs", "Diamonds", "Hearts", "Spades"};
  const string Ranks[] = {"Ace", "2", "3", "4", "5", "6", "7", "8",
    "9", "10", "Jack", "Queen", "King"};

  // Initialize cards
  for (int I = 0; I < NUMBEROFCARDS; I++)
    Deck[I] = I;

  // Shuffle the cards
  Shuffle(Deck, NUMBEROFCARDS);

//Reber's loop


while (SuitCount < 4) 
{
// Draw a card
// Which suit is it?
    if(Ranks[Deck[CardDrawCount] % 13] == 0 ) 
    {
        ClubsCount++; // Bump Suit counter
        if(ClubsCount < 2) { // 1st of suit? Print to screen
             cout << Ranks[Deck[CardDrawCount] % 13] << " of " << Suits[Deck[CardDrawCount] / 13] << endl;
            SuitCount++;
        }
        CardDrawCount++; // Up overall counter
    }
    if(Ranks[Deck[CardDrawCount] % 13] == 1 ) 
    {
        DiamondsCount++; // Bump Suit counter
        if(DiamondsCount < 2) { // 1st of suit? Print to screen
             cout << Ranks[Deck[CardDrawCount] % 13] << " of " << Suits[Deck[CardDrawCount] / 13] << endl;
            SuitCount++; // 1st of suit? Bump counter
        }
        CardDrawCount++; // Up overall counter
    }
    if(Ranks[Deck[CardDrawCount] % 13] == 2 ) 
    {
        HeartsCount++; // Bump Suit counter
        if(HeartsCount < 2) { // 1st of suit? Print to screen
             cout << Ranks[Deck[CardDrawCount] % 13] << " of " << Suits[Deck[CardDrawCount] / 13] << endl;
            SuitCount++;
        }
        CardDrawCount++; // Up overall counter
    }
    if(Ranks[Deck[CardDrawCount] % 13] == 3 ) 
    {
        SpadesCount++; // Bump Suit counter
        if(SpadesCount < 2) { // 1st of suit? Print to screen
             cout << Ranks[Deck[CardDrawCount] % 13] << " of " << Suits[Deck[CardDrawCount] / 13] << endl;
            SuitCount++;
        }
        CardDrawCount++; // Up overall counter
    }
} 

  return 0;
}

Recommended Answers

All 3 Replies

What the program is supposed to do is show you randomly show u 4 suits of card and how many picks it took for 1 card from each suit to show up. I've been working on it for 4 days and I can't come to any resolution. Thanks again, your efforts are deeply appreciated.

What else does it say?

Use code tags..... It makes it much easier for us to understand your code when you use code tags

When I compiled your code, I get an error on this line

if(Ranks[Deck[CardDrawCount] % 13] == 0 )

The reason for this is that this expression becomes (when CardDrawCount is equal to 0)

if("Ace"==0 )

which leads the compiler to assume that you are trying to compare a string to an integer which is not possible. This error repeats itself in many places.

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.