I tried different methods but eventually got errors. Please give a solution and a brief explanation of the concept.
uint8_t **subBytes()
{
    int i,j;
    uint8_t r,c;
    uint8_t t[4][4];
    for(i=0;i<4;i++)
    {
        for (j=0;j<4;j++)
        {
            r = pt[p1][j] & 0xf0;
            r = r >> 4;
            c = pt[p1][j] & 0x0f;
            t[i][j] = (uint8_t *) malloc(sizeof(uint8_t));
            t[i][j] = sBox[r][c];
        }
        p1++;
    }
    return t;
}
int main()
{
    uint8_t **temp;
    temp = subBytes();
    for(i=0;i<4;i++)
    {
        for(j=0;j<4;j++)
        {
            printf("%x  ", temp[i][j]);
        }
        printf("\n");
    }
}
This is my original code. Here, I used malloc, but then too it is not working.
 
     
     
     
    