[Solved] how to copy 1-D array to 2-D array


You need a char for the final \0, I have used a loop to get the 2 char

#include <string.h> 
#include <stdio.h> 



int main(void) { 
    static char pvtsWsMthDayTab[25]="312831303130313130313031"; 
    char sDaysInMth[12][3] ; 

    memset(sDaysInMth, 0, sizeof(sDaysInMth)); 

    for(int i = 0; i < 12; i++) { 
        for (int j = 0; j < 2; j++ ) { 
            sDaysInMth[i][j] = pvtsWsMthDayTab[i * 2 + j ]; 
        } 
    } 

    for(int i = 0; i < 12; i++) { 
        printf("%s\n",sDaysInMth[i]); 
    } 


    return 0; 
} 

solved how to copy 1-D array to 2-D array