I cannot seem to match up the strings when looking for them in my SymTab. I know the hash function works and will always hash the name to the correct location, so it must be something semantic I'm doing when trying to compare the strings. Please help.
Code:
struct SymEntry* FindName(struct SymTab *ATable,
const char * Name) {
printf("\nFinding Name: \"%s\" ", Name);
int comp;
int hashValue = hash(Name,ATable);
char n[200];
int nameLength;
struct SymEntry *currentEntry;
strcpy(n, Name);
nameLength = strlen(n) + 1;
if(ATable->Contents[hashValue] == NULL){
printf("\nATable->Contents at hashValue were NULL, returning NULL\n");
return NULL;
} /*else */
for(currentEntry = ATable->Contents[hashValue];
currentEntry->Next != NULL; currentEntry = currentEntry->Next) {
printf("\ncurrentEntry = %s\n",currentEntry->Name);
printf("\ncomparing n = %s to currentEntry = %s\n", n , currentEntry->Name);
comp = strcmp( n, currentEntry->Name);
printf("\ncomp = %d",comp);
if (comp == 0){
return currentEntry;
}
}
return NULL; /* wasn't found in the list at the hash value */
};
the printf's are just for debugging, sorry if it makes a more jumbled code.