Yes, I'm still having problems coding my SymTab.h file.
Here is what the compiler is giving me:
SymTab.h: In function 'EnterName':
SymTab.h:137: warning assignment makes pointer from integer without a cast
SymTab.h: At top level:
SymTab.h:158: error: conflicting types for 'FindName'
SymTab.h:137: error: previous implicit declaration of 'FindName' was here
SymTab.h: In function 'EnterName':
SymTab.h:137: warning: assignment makes pointer from integer without a cast
SymTab.h: At top level:
right, so I don't see where there's an integer assignment in this code at all, but maybe somebody can help me see it.
Here's the code segment that tries to do the assignment, line 137 highlighted for convenience.
Code:
bool EnterName(struct SymTab *ATable, const char *Name,
struct SymEntry * *AnEntry) {
int hashValue = hash(Name,ATable);
char n[200];
int nameLength;
struct SymEntry *currentEntry;
struct SymEntry *newEntry;
strcpy(n, Name);
nameLength = strlen(n) + 1;
if(ATable->Contents[hashValue] == NULL) {
newEntry = (struct SymEntry*)malloc(sizeof(struct SymEntry*) + nameLength);
newEntry->Name = n;
newEntry->Next = NULL;
ATable->Contents[hashValue] = newEntry;
AnEntry = &newEntry;
return false;
} else {
currentEntry = FindName(ATable, Name);[
if(currentEntry != NULL) return true;
/* else if( currentEntry == NULL )*/
currentEntry = ATable->Contents[hashValue];
while(currentEntry->Next !=NULL) {
currentEntry = currentEntry->Next;
}
newEntry = (struct SymEntry*)malloc(sizeof(struct SymEntry*) + nameLength);
newEntry->Name = n;
newEntry->Next = NULL;
currentEntry->Next = newEntry;
}
};
and here's the method I'm trying to use for the assignment, line 158 highlighted.
Code:
struct SymEntry* FindName(struct SymTab *ATable,
const char * 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){
return NULL;
} /*else */
for(currentEntry = ATable->Contents[hashValue];
currentEntry->Next != NULL; currentEntry = currentEntry->Next) {
comp = strcmp( n, currentEntry->Name);
if (comp == 0){
return currentEntry;
}
}
return NULL; /* wasn't found in the list at the hash value */
};
I know it's a lot of debugging to ask, but I'm really stumped at this point after going through this code.