good call, thanks.
Type: Posts; User: P3nGu1N
good call, thanks.
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...
Re-read my assignment sheet, and it does seem to want all coding in a separate SymTab.c file. I duplicated my folder, just in case something bad happened when I transferred all the methods over, but...
but the .c file is the driver my professor gave me. I assumed he wanted all of the coding done in the .h file.
Thanks for the explanation, it makes sense that it has to be declared before use.
Alright, put it at the top of my SymTab.h and got a clean compile.
Okay, so now I'm really confused why my other methods all compiled, but not this one without a prototype.
Should I have...
do you mean something like this before the method?
struct SymEntry * FindName(struct SymTab *ATable,
const char * Name);
or, what do you mean by 'prototype'?
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...
double percent needs a semicolon -
double percent;
if (sum==8
eight++);
should probably be
; <- also, what is this??!!
that is a semicolon. (Yeah you probably knew that, but you can also end your methods with them. It doesn't matter whether it's there or not, just different style of...
That's true, but how do I access the previous SymEntrys in the list after I destroy the last one? I was trying that outer while loop to destroy the last one, then the new last one, until the first...
What I'm trying to do is free the contents of a list of SymEntry s in the array associated with Contents of a SymTab. If I can't use a pointer, p to point to the address location where each SymEntry...
The sad thing is I've already created this program in Java last year. It's much easier for me to look at abstract data types like chain bucket hashing from an object oriented language.
you made a very valid point... I'm really just trying to destroy each list item in an array of lists, which means I should only have to access each Contents[i] once provided it wasn't NULL to begin...
Well, I've known '\0' == NULL, but 0 == NULL? I miss programming in Java...
Alright, just tried this:
void DestroySymTab(struct SymTab *ATable) {
int i;
struct SymEntry *p;
for (i = 0; i < ATable->Size; i++) {
while(ATable->Contents[i] != NULL) {
/*p =...
Alright, well it keeps spitting out address:0 in the console, let me try the Contents[i] alone one for you.
Shouldn't Contents[i] be set to NULL when I set the pointer p to NULL when it's pointing to it?
Okay, trying the other suggestion, bbs.
Tried it, and nope the infinite loop is in the outer while statement.
void DestroySymTab(struct SymTab *ATable) {
int i;
struct SymEntry *p;
for (i = 0; i < ATable->Size; i++) {...
Well, right now for testing purposes I haven't implemented adding anything past one name, and SymEntry->Next should be NULL terminated for that one.
bool EnterName(struct SymTab *ATable, const...
Shouldn't this become NULL and exit the loop? It certainly doesn't...
void DestroySymTab(struct SymTab *ATable) {
int i;
struct SymEntry *p;
for (i = 0; i < ATable->Size; i++) {...
odd, it compiled this time with:
free(ATable);
Might have just been the iMac version of gcc that didn't like it? I just tried on my Window's downloaded version of gcc... Well, thanks for...
alright, maybe I should post my constructor to clarify things:
struct SymTab * CreateSymTab(int Size) {
int i;
if( Size > 0){
tableSize = Size;
}
I'm new to the board, so first - hi.
I'm also fairly new to C programming, but have a good background in Java and a little C++.
There's part of a program that I'm stuck on how to do:
...