I'm trying to write C code to shuffle a 52 card deck with 2 character arrays. One for the suit and the other for the value. The arrays are really killing me and I've searched for about 2 hours now and just not finding what I need. I'm not sure how to shuffle the cards within the array. Professor said to try switching 2 numbers within the array by running a for loop 1000 times, but just confused. I'm guessing just initialize the arrays like this:
Code:
char number[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'J', 'Q', 'K', 'A' };
char suit[] = { 'c', 'd', 'h', 's' };
I've read about pointers? Not sure exactly what that means and saw others with "const" in front of the arrays but haven't learned anything about those yet. I honestly don't even know where to go from there. I just need to write a couple functions to shuffle and deal the cards and I can go from there. This is what I have so far:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int shufflenumber(int[]);
char shufflesuit(char[]);
int dealnumber(int[]);
char dealsuit(char[]);
int main(void)
{
char number[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'J', 'Q', 'K', 'A' };
char suit[] = { 'c', 'd', 'h', 's' };
system("PAUSE");
return 0;
}
int shufflenumber(int number)
{
int i=0;
srand(time(NULL));
for(i=0; i<1000; i++)
I'm not sure what to do within the for loop which is why it isn't completed