Today is: 8 January, 2012
Check todays hot topics

structures

Card Shuffler in C

There are a lot of card shuffling examples out there, I guess to show examples of rand(). 20 minutes and some ghetto code later, here is one with card structures defined. It takes one argument, which is the number of decks you want to shuffle. Read the code to learn more.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
 
struct card {
    char sname;
    char lname[12];
    char suit[12];
};
 
char snames[14] = "A23456789TJQK\0";
 
char *lnames[14] = {
    "Ace",
    "Two",
    "Three",
    "Four",
    "Five",
    "Six",
    "Seven",

Syndicate content