i wanted to find the duplicates present in an array of pointers.the code is shown below.when i run this application it is gining segmentation fault.But when i extract this f
char *a[20]; // an array of char pointers. 20 elements in the array.
char *findduplicates(char *arr[3],int count)
// arr is an array of char pointers, with 3 elements in the array.
findduplicates(a, count); // this will just pass 3 of the 20 pointers
// thus when you try to access a[3], it will probably seg-fault.
try this instead:
char *findduplicates(char **arr,int count)
[edit]
Maybe I'm wrong about this. I just wrote a small test program, and it wouldn't crash even if declared the function parameter as char *a[0]. But try my suggestion anyway. Memory bugs don't always make stuff crash...