I am learning how to use structures in an attempt to make a card game. I've been messing with this for roughly forever and I cannot get the printf statement to work how I would like. I think it has something to do with cc2
not being properly assigned to ctwo.typ
but I'm really at a loss as to what to do about it.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct
{
char typ[20];
int num;
} card;
int main(void)
{
char cc2[] = "Two of Clubs";
card ctwo;
ctwo.typ[20] = *cc2;
ctwo.num = 2;
//The output of the following is "Two of Clubs"
printf("%s\n", cc2);
//The output of the following is "2, "
printf("%i, %s\n", ctwo.num, ctwo.typ);
//The output of the following is "2, (null)"
printf("%i, %s\n", ctwo.num, ctwo.typ[0]);
return 0;
}