I really appreciate all the suggestions, but I'm not any less confused now. The example program given uses char*, but before we were talking about using const char [][].
Maybe it helps if I just give the whole code of my test program. It does compile now and It doesn't crash either. Unfortunatly however, it doesn't do what I want it to do. It just uses "result" as whatever value I gave it at the declaration.
This is what I have now:
The function:
And in the main for testing this function:Code:
int stringcheck(const char* string1_to_check_for,const char* string2_to_check_for,const char array_to_check[][8],int length_of_array){
int i=0;
int result=0;
for(i = 0; i < length_of_array; i++)
{
if (strcmp(string1_to_check_for, array_to_check[i]) == 0 ||
strcmp(string2_to_check_for, array_to_check[i]) == 0)
{
return result = 1;
break;
}
}
return result = 0;
}
Maybe you can help me, using what I have so far?Code:const char comb_array[][8] =
{ "13",
"26",
"158",
"86",
"88",
"1212",
"142",
"89",
"14",
"410",
"1116",
"168",
"12",
"34"
};
int result=5;
int startype1 = 1;
int startype2 = 4;
int comb_array_pointer = 14;
char current_comb1[8];
char current_comb2[8];
sprintf(current_comb1, "%d%d",startype1,startype2);
sprintf(current_comb2, "%d%d",startype2,startype1);
printf("checking for the strings: '%s' '%s' \n", current_comb1, current_comb2);
stringcheck(current_comb1,current_comb2,comb_array,comb_array_pointer);
printf("String found true/false (1/0): %d\n",result);