It seems like the array named "words" is not being read into function inDictionary properly, and I know the program experiences the bus error at the moment it tries to compute the strcmp function. I've had no luck troubleshooting though..help anyone??

Last edited by 3MGFX; 02-04-2009 at 09:24 PM.
Reason: Edited out irrelevant portion of code

^^You're absolutely right, man. But if you read the bottom of my post, you would see that I was trying to explain the way I was approaching the problem..and maybe someone more experienced could show me a different way of looking at it so that way I could actually learn something..as oppose to someone just showing me where the errors were..

I'm getting a "segmentation fault" error message now..and I believe that has something to do with the manner in which I'm allocating my memory. But I don't understand why that would change by just moving it out of the previous for loop as instructed.

I turned in the assignment already..but I would love to get this working so that I may play around with it and optimize it; that would be good practice in the long run. I'll repost my entire algorithm as well.

Your approach sucks - happy now?
How many times do you call strlen(jumble).

> But I don't understand why that would change by just moving it out of the previous for loop as instructed.
You don't? It's worse than I thought.

Can you figure out why
if(words == NULL)
should be outside the loop as well?

> words[i] = (char*)malloc(sizeof(char)*MAX_SIZE);
Or why you SHOULD check this for NULL

> ifp = fopen("jumble.txt", "r");
And this for NULL as well.

> free(words);
You should free each words[i] before this.

> But if you read the bottom of my post
But if you read the top, the story is different.

> if(inDictionary(jumble, words, size_of_dictionary) == 1)
Strange, the function returns the INDEX of where the string is found.
Being an index, zero is also a valid result, AND is also your "not found" result as well.