Hi everyone,
This is my first post, I'm hoping for a little help, as I'm getting a little burnt out on the following idea:
I'm trying to create a char array with 312 variables. This will represent 6 packs of cards all shuffled together. (Obviously, I'm working on a card game). I'm trying to get program to a testable point, where the user can enter a number from 0-311 and obtain the values contained in my arrays.
For example:
User enters: 0
Output: Ace of hearts, 1 point.
So.... I'm using a number of arrays to accomplish this:
Code:
#include <stdio.h>
#include <stdlib.h>
main(){
int d, e, j;
d = 0;
e = 0;
char Six_deck1[311]; // Controlled by int j - used to store text description
int Six_deck2[311]; // Controlled by int j - used to store card values
int pointvalue[13] = {1,2,3,4,5,6,7,8,9,10,10,10,10}; //controlled by int d - All face cards worth 10 points.
char *value[13] = {"Ace", "Deuce", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}; //controlled by int d
char *suits[4] = {"Hearts", "Diamonds", "Clubs", "Spades"}; //controlled by int e
//m = 0;
//Setting values to arrays
for (j=0; j<=311; j++)
{
printf("Card %d set with the %s of %s and %d point(s).\n", j, value[d], suits[e], pointvalue[d]);
//INSERTION POINT OF SPRINTF? TO SET Six_deck1 ??? SEE BELOW.....
Six_deck2[j]=pointvalue[d];
d++;
if (d>12) {d=0;e++; ;} //Resets the card value to Ace after King has been assigned and advances suit.
if (e>3) {e=0; ;} // Resets suits to "Hearts" after all "Spades" have been used, total cards (ie:packs) determined by j.
}
printf("\n\n");
system ("pause");
system ("cls"); //Need stdlib.h
for (j=0; j<=311; j++)
{
printf("Array %d has a value of %d\n\n", j, Six_deck2[j]);
}
return 0;}
So far, I can easily assign the points in the pointvalue array to my Six_deck2 array. But, this is where I'm stumped. Now, I need to add 2 outputs to a single array.
I'm would love to use sprintf in the following manner:
sprintf (Six_deck1, "%s of %s", value[d], suits[e]);
But it doesn't work. Any suggestions on this? I figured this would be an 'easy' way to set my char Six_deck1 array , without painstakingly entering every card by hand.
Thanks for any help....
Todd V