bsearch of a dynamically allocated 2D array in C

I'm writing a dictionary in C by loading each of the dictionary's words to a dynamically allocated array. To search the array, I'm trying to use stdlib's bsearch function, but cannot get it to work.

I researched the function and came across C++ reference's C Reference function bsearch().

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char str_array[][20] = {"gh","ef","cd","ab"};    

int main ()
{
    char * ptr_item;
    char searchkey[20];

    printf ("Enter a searchkey: ");
    scanf ("%s", &searchkey);

    /* sort the elements of the array */
    qsort(str_array,4,20,(int(*)(const void*,const void*)) strcmp);

    /* search for the searchkey */
    ptr_item = (char*)
    bsearch (searchkey,str_array,4,20,(int(*)
        (const void*,const void*)) strcmp);

    if (ptr_item!=NULL)
        printf ("%s found in the array.\n",ptr_item);
    else
        printf ("%s not found in the array.\n",searchkey);
    return 0;
}

When I ran their code verbatim and searched for "ab", the program printed out ab found in the array. as expected. However, when I changed the programme to use an array like mine, ab was not found.

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

char **str_array; //
int main ()
{
    char * ptr_item;
    char searchkey[20];

    printf ("Enter a searchkey: ");
    scanf ("%s", searchkey);

    str_array = malloc(4 * sizeof(char *)); //

    for (int i = 0; i < 4; i++) // 
    {
        str_array[i] = malloc(sizeof(3 * sizeof(char))); // 
    }

    str_array[0] = "gh\0"; //
    str_array[1] = "ef\0"; //
    str_array[2] = "cd\0"; //
    str_array[3] = "ab\0"; //


    /* sort the elements of the array */
    qsort(str_array,4,20,(int(*)(const void*,const void*)) strcmp);

    /* search for the searchkey */
    ptr_item = (char*)
        bsearch (searchkey,str_array,4,20,(int(*)
        (const void*,const void*)) strcmp);

    if (ptr_item!=NULL)
        printf ("%s found in the array.\n",ptr_item);
    else
        printf ("%s not found in the array.\n",searchkey);

    for (int i = 0; i < 4; i++) //
    {
        free(str_array[i]); //
    } 

    free(str_array) //

    return 0;
}

What is the error in the second programme?