/*binary search program using dynamic allocation of strings */ #include #include #include void main() { int i,mid,low,high,n,s; char **a,**key; printf("enter the number of strings of n "); scanf("%d",&n); a=(char **)malloc(n*sizeof(char *)); key=(char **)malloc(1*sizeof(char *)); for(i=0;i
It looks like you want to use key to store a string, but you have declared key as char ** and used malloc twice with it, once as if it is char ** and then as if it is char *. That seems really unusual to me, I think you want key to be a char * so you can dynamically allocate space to store a string to be the key. These videos might help you out and give you ideas to solve the problem you are trying to solve: Binary Search Algorithm: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Uuyv88Tn9iU.html Dynamically Allocate Memory for Array Of Strings: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-4_2BEgOFd0E.html Sorting An Array Of Strings: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-LZNxRSoEG2M.html