I\'m writing a program to write card values into a 52 spot character multi-dimensional array. This program is one test array that I will write as a function into the main progra
You need to doing a strcpy and not assigning string literals directly. Also, the array usage is wrong.
The code should be like below:
#include <stdio.h>
#include <string.h>
int main ()
{
char CardValue[52][6];
int i;
/* Not clear what you are trying in the below 2 lines. But, it'll not work :-) */
/*CardValue[i][6]=i;
CardValue[i];*/
for (i=0;i<52;i++)
{
switch (i%13)
{
case '0': strcpy(CardValue[i],"ACE");
break;
case '1': strcpy(CardValue[i],"2");
break;
/** Do the same way for other case **/
}
}
}
You should #include <string.h>
and do something like this:
case '0': strcpy(CardValue[i],"ACE");
etc. Also note, that CardValue[i];
has no effect at all. You should also remove CardValue[i][6]=i;
, I don't really know what you meant by that, but it surely should not be there.