BubbleSorting cards not working?

So I have to write a poker game program, and I have to sort the cards by value before checking them. I have the functions to deal the cards to each player. I just need to sort them. Here is the bubblesort function.

void BubbleSort(Card Hands[][handlength])
{

/*
for (int j = 0; j < 4; j++)
{
int i;
bool Sorted;
Card Temp;
int Sorthand;
Sorthand = handlength - 1;
do {
Sorted = true;
for (i = 0; i < handlength - 1; i++)
if (Hands.Value [j][i] > Hands.Value [j][i + 1])
{
Temp.Value = Hands.Value [j][i];
Hands.Value [j][i] = Hands.Value [j][i + 1];
Hands.Value [j][i + 1] = Temp.Value;
Temp.Suit = Hands.Suit [j][i];
Hands.Suit [j][i] = Hands.Suit [j][i + 1];
Hands.Suit [j][i + 1] = Temp.Suit;
Sorted = false;
}
else;
Sorthand--;
} while (!Sorted);

}
*/
//Something is wrong with Hands.Value & Hands.Suit

}

Cards is a struct that holds the suits and values by the way. I just can't get this function to work for some reason.

It gives me a squiggly line underneath the Hands in Hands.Value and Hands.Suit, and when I go over it, it says "Error: expression must have class type" I'm not sure what to do in this case. I don't know if I have to post my whole code to help with this function.
First of all, I see that you are new to the forum, so don't worry about it this time, but it makes life a huge amount easier if you use [.code]<code goes here>[./code] tags. (Without the period at the start of each tag).

Anyways, the problem is that arrays are treated as pointers and cannot have fields.

The solution is to have Hands[j][i].Value instead of Hands.Value[j][i] *note where the [j][i] goes.
Topic archived. No new replies allowed.