C Experts, I have an array of pointers to strings. I need to compare each array element with all other array elements and throw error if they are same. Here is the piece of code I have written and got stuck. Please help me.
# define FOUND 1
# define NOTFOUND 0
int k,flag,a;
char cmp_string[10]; //used to get one array element to compare with all other array elements
char *values[]={010,020,030,040}; //valid case that s how it should be
char *vales[]={010,020,020,030}; wrong or throw error because in array i should have only unique values
int size=4;
for(k=0; k<=size;k++){
strcpy(values[k],cmp_string);
flag=NOTFOUND;
int counter=k+1;
for(int n=counter;n<=size;n++)
{
a=((strcmp(values[n],cmp_string) || (strcmp(values[k-1],cmp_string)))
// stuck here what if k value is 2 I wont be able to compare with zero or first element of array.
if(a==0){
throw error same name for the operation
flag=FOUND;
break;
}
}//for int n;
}//for int k;
if(flag==NOTFOUND){
True or PASS
}
}