normally append_test_data[MAX_LENGTH]="";
is just \0 stored in it do you want to make user each time get string from him through the loop and then compare it ? also note that int n=1 that will start from 2nd array count not first since arrays start from 0 could you also post full code to see whats wrong with it
i repeat my prob,
i have an array with 5 row of data and each row has these data:
const_array[0][]=a1,b1,c3,
const_array[1][]=a2,b1,c3,
const_array[2][]=a3,b2,c2,
const_array[3][]=a2,b3,c1,
const_array[4][]=a3,b2,c1,
then i want each of them are compared to this :
char append_test_data[100]="";
for note,the data in this array is always randomly changed but only 1 data each time.so,this means,the const_array just compare to 1 data in append_test_data in a time.
example:
append_test_data =a2,b1,c3, =>the program cant compare them
but if append_test_data=a3,b2,c1, =>only program can compare them.
whats wrong with my program?
if ((in_const = fopen(const_file, "r+")) == NULL)
{
fprintf(stderr, "Cannot open constraint file.\n");
exit(0);
}
char const_array[100][100];
int m=0 ;
while(!feof(in_const)& m <=100)
{
fgets(const_array[m],100,in_const);
m++;
}
for(int n=0;n<=m;n++)
{
if(strcmp(const_array[n],append_test_data) == 0)
{
printf("Append data is =%s\n",append_test_data);
printf("constraint is found=%s\n",const_array[n]);
getch();
exit(0);
}
}
actually,
i call the file and load to an array in the same function.maybe it effect sumthing.