This is my code:
if(strcmp(pch,map[i].name)==0){
printf("Equal\n");
return 0;
}
pch
is read from a file, map[i].name
has a known size of 64.
This works great for strings smaller than 64. when comparing these two strings below of size 63:
file11111111111111111111111111111111111111111111111111111111111
and
file11111111111111111111111111111111111111111111111111111111111
everything is peachy and the result as expected is equal, but when these two (of size 64) are compared:
file111111111111111111111111111111111111111111111111111111111111
and
file111111111111111111111111111111111111111111111111111111111111
the return is false. I thought of doing:
if(strncmp(pch,map[i].name,64)==0){
printf("Equal\n");
return 0;
}
And it does work for strings of exact size of 64, but for strings that are smaller the result is random. What kind of quirkiness am i dealing with here?
EDIT: this is the full code:
char * pch;
char tempFilesNeeded[100*64+100];
strcpy(tempFilesNeeded,map[i].filesNeeded);
pch = strtok(tempFilesNeeded,",");
while (pch != NULL)
{
if(strcmp(pch,map[i].name)==0){
printf("Equal\n");
return 0;
}
pch = strtok (NULL, ",");
}