Hello all. Long time reader, first time poster.

My problem is pretty huge, and I don't even really know where to start explaining lol.

Basically what is happening is I'm expecting the arrays, cardvalue[] in particular, to only fill with 52 numbers. I'm initializing them to 52, but when I pass to the "FillShuffle" function, the outcome is extremely unexpected.

After being passed and "filled", the arrays somehow are combining into each other. For example, doing a display of the elements in "cardvalue[]", comes up with the first 0-51 elements containing the correct numbers, but element 53 (52 in actuality) and up contain, for some strange reasons, the other array elements?

For instance, cardvalue[53] will contain straightflushnumber[0], cardvalue[54] will contain straightflushnumber[1], etc.

Very strange, and it is creating a problem with the shuffle function. Even weirder, which arrays are affected change when i change the order of initialization.

For instance, if i "int cardvalue[52], cardsuit[52], straightflushnumber[52]", than cardvalue[53] will be equal to cardsuit[0] instead of straightflushnumber[0].

Eghads, lots of problems, but hopefully i will find a way to fix it with you guys' help.

And now, my code. I'm not the greatest programmer right now, and I know there's better ways of doing things, but for now I'd just like to understand why the array combining thing is happening.

Without further ado:

Code:

int cardcounter;
// Card Class
struct Card {
        int number;
        char *cardname;
        int value;
        int cardsui;
        int villain2;
        int straightflu;
        int straightac;
        char *cardname2;
};

        // Function declerations for filling, and shuffling the deck
        void fillDeck(Card * const, char *[], int [], int[], int[], char *[], int[], int[]);
        void shuffle(Card * const);

        // Arrays to keep track of values
        char * cardfilename[52];
        char * cardfilename2[52];
        int cardvalue[52];
        int straightflushnumber[52]
		int cardvillain2[52];
		int straightacenumber[52];
		int cardsuit[52];

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void __fastcall TForm1::ShuffleFill(TObject *Sender)
{

        handdeterminecounter == 1;
        // Card Dealing Variables
        Card deck[52];
        int number[] = {1};
        int value[52] = {1,2,3,4,5,6,7,8,9,10,11,12,13,1,2,3,4,5,6,7,8,9,10,11,12,13,1,2,3,4,5,6,7,8,9,10,11,12,13,1,2,3,4,5,6,7,8,9,10,11,12,13};
        int villain2[52] = {14,2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13};
        char *cardname[52] = { "cards/diamondsace.bmp", "cards/diamondstwo.bmp", "cards/diamondsthree.bmp", "cards/diamondsfour.bmp", "cards/diamondsfive.bmp", "cards/diamondssix.bmp", "cards/diamondsseven.bmp", "cards/diamondseight.bmp", "cards/diamondsnine.bmp", "cards/diamondsten.bmp", "cards/diamondsjack.bmp", "cards/diamondsqueen.bmp", "cards/diamondsking.bmp", "cards/heartsace.bmp", "cards/heartstwo.bmp", "cards/heartsthree.bmp", "cards/heartsfour.bmp", "cards/heartsfive.bmp", "cards/heartssix.bmp", "cards/heartsseven.bmp", "cards/heartseight.bmp", "cards/heartsnine.bmp", "cards/heartsten.bmp", "cards/heartsjack.bmp", "cards/heartsqueen.bmp", "cards/heartsking.bmp", "cards/spadesace.bmp", "cards/spadestwo.bmp", "cards/spadesthree.bmp",
        "cards/spadesfour.bmp", "cards/spadesfive.bmp", "cards/spadessix.bmp", "cards/spadesseven.bmp", "cards/spadeseight.bmp", "cards/spadesnine.bmp", "cards/spadesten.bmp", "cards/spadesjack.bmp", "cards/spadesqueen.bmp", "cards/spadesking.bmp", "cards/clubsace.bmp", "cards/clubstwo.bmp", "cards/clubsthree.bmp", "cards/clubsfour.bmp", "cards/clubsfive.bmp", "cards/clubssix.bmp",
        "cards/clubsseven.bmp", "cards/clubseight.bmp", "cards/clubsnine.bmp", "cards/clubsten.bmp", "cards/clubsjack.bmp", "cards/clubsqueen.bmp", "cards/clubsking.bmp"};
        int cardsuit[52] = {1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4};
        char *cardname2[52] = { "cards/diamondsace.bmp", "cards/diamondstwo.bmp", "cards/diamondsthree.bmp", "cards/diamondsfour.bmp", "cards/diamondsfive.bmp", "cards/diamondssix.bmp", "cards/diamondsseven.bmp", "cards/diamondseight.bmp", "cards/diamondsnine.bmp", "cards/diamondsten.bmp", "cards/diamondsjack.bmp", "cards/diamondsqueen.bmp", "cards/diamondsking.bmp", "cards/heartsace.bmp", "cards/heartstwo.bmp", "cards/heartsthree.bmp", "cards/heartsfour.bmp", "cards/heartsfive.bmp", "cards/heartssix.bmp", "cards/heartsseven.bmp", "cards/heartseight.bmp", "cards/heartsnine.bmp", "cards/heartsten.bmp", "cards/heartsjack.bmp", "cards/heartsqueen.bmp", "cards/heartsking.bmp", "cards/spadesace.bmp", "cards/spadestwo.bmp", "cards/spadesthree.bmp",
        "cards/spadesfour.bmp", "cards/spadesfive.bmp", "cards/spadessix.bmp", "cards/spadesseven.bmp", "cards/spadeseight.bmp", "cards/spadesnine.bmp", "cards/spadesten.bmp", "cards/spadesjack.bmp", "cards/spadesqueen.bmp", "cards/spadesking.bmp", "cards/clubsace.bmp", "cards/clubstwo.bmp", "cards/clubsthree.bmp", "cards/clubsfour.bmp", "cards/clubsfive.bmp", "cards/clubssix.bmp",
        "cards/clubsseven.bmp", "cards/clubseight.bmp", "cards/clubsnine.bmp", "cards/clubsten.bmp", "cards/clubsjack.bmp", "cards/clubsqueen.bmp", "cards/clubsking.bmp"};
        int straightflushnumber[52] = {1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,55};
        int straightacenumber[52] = {14,2,3,4,5,6,7,8,9,10,11,12,13,29,17,18,19,20,21,22,23,24,25,26,27,28,44,32,33,34,35,36,37,38,39,40,41,42,43,58,46,47,48,49,50,51,52,53,54,55,56,57};

        // Randomize
        srand(time(0));
        fillDeck(deck, cardname, value, villain2, cardsuit, cardname2, straightflushnumber, straightacenumber);
        //shuffle(deck);

        // Start Seat counter
        seatcounter = 1;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void fillDeck(Card * const wDeck, char *wCardname[], int wValue[], int wVillain2[], int wCardsui[], char *wCardname2[], int wStraightflu[], int wStraightac[])
{
	int k;
	k = 1;

	for(int i = 0; i < 52; i++)
	{
	//int placeholder = (i % 52);
	wDeck[i].number = k;
	k++;
	// Temporary Setup
	wDeck[i].cardname = wCardname[i];
	wDeck[i].value = wValue[i];
        wDeck[i].villain2 = wVillain2[i];
	wDeck[i].cardsui = wCardsui[i];
	wDeck[i].cardname2 = wCardname2[i];
	wDeck[i].straightflu = wStraightflu[i];
        wDeck[i].straightac = wStraightac[i];
	// Temporary Setup 2
	cardfilename[i] = wDeck[i].cardname;
	cardfilename2[i] = wDeck[i].cardname2;
	cardvalue[i] = wDeck[i].value;
        cardvillain2[i] = wDeck[i].villain2;
	cardsuit[i] = wDeck[i].cardsui;
	straightflushnumber[i] = wDeck[i].straightflu;
    straightacenumber[i] = wDeck[i].straightac;
	}

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void shuffle(Card * const wDeck)
{
	for ( int i = 0; i < 52; i++ )
	{
	int j = rand() % 52;
	Card temp = wDeck[i];
	wDeck[i] = wDeck[j];
	wDeck[j] = temp;
	cardfilename[i] = wDeck[i].cardname;
	cardfilename2[i] = wDeck[i].cardname2;
	cardvalue[i] = wDeck[i].value;
        cardvillain2[i] = wDeck[i].villain2;
	cardsuit[i] = wDeck[i].cardsui;
	straightflushnumber[i] = wDeck[i].straightflu;
    straightacenumber[i] = wDeck[i].straightac;
    Form1->Button5->Click();
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I know this is probably a very confusing problem, but hopefully someone will be able to offer a bit of advice, that will lead to more thinking on my part, and eventually, a solution :)