I have been new to C & C++ programming.I got a task to search a string array for duplicate string.If a array consists of a string which is passed as a argument then it should not add the string into the array.
In the following code I have been passing a string(to be search for repetation) as key.
I am going to search in array which is a 2D array declared as char array[100][20].
int arraySearch(char *key)//string to be searched
{
int loc=0;
for(loc;loc<=count;loc++) //count :size of array already defined
{
if((strcmp(array[loc],key))==0)
{
break;
}
else
{
strcpy(array[count],key);
count++;
}
}
return 0;
}
After running this code m getting error like segmentation fault[coer dumped]
Do anyone has idea abt this?
please share it
Warm regards,
Sumit


Sign In
Create Account

Back to top









