Incompatible pointer to character conversion

前端 未结 2 1656
失恋的感觉
失恋的感觉 2021-01-29 11:50

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

2条回答
  •  时光说笑
    2021-01-29 12:09

    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 
    #include 
    
    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 **/
    
            }
         }
    }
    

提交回复
热议问题