Hot answers tagged

1 vote
Accepted

Speller skips first word in dictionary

I'm surprised there aren't more problems! Look at the following code: while ((ch = fgetc(d)) != EOF) { fscanf(d, "%s", dictword); The while statement scans the first letter ...
user avatar
  • 63.1k
1 vote
Accepted

Speller not working! What's going on?

First, since the global declarations and other code that comes at the top of the file weren't included, I've had to guess at some things to test the code. I suspect that sumstring, used in the hash ...
user avatar
  • 63.1k
1 vote
Accepted

PSet2 Crack: crypt() returning same hash

I'd say crypt works as expected, and is not the cause for your problem. Passing z or z_val does the same thing, as arrays are passed as a pointer to their first element. Same goes for returning o or ...
user avatar
  • 20.7k
1 vote
Accepted

Question about PSet 2 Crack

A couple of things, if your if condition returns 1 in case of error you don't need an else clause, this only complicates the code. In addition you should print the correct way to use the program, a ...
user avatar
  • 5,172
1 vote

pset1 always adding extra one space on each Hash row

You set height equal to four. This also sets j to four. See how this works on the first line: i = 0 by definition, so you print a " " every time j is above i and deduct one from j. You can repeat ...
user avatar
  • 31
1 vote
Accepted

The predefined login function does not seem to be working in finance

Try any user with the password password. All users are created with that same password. This hashp = generate_password_hash("password") treats password as a string literal, because of the ". You ...
user avatar
1 vote
Accepted

Segmentation Fault on Hashtable

new->s=""; lets new->s point to an empty string stored in a read-only area. strcpy(new->s,val); then tries to write to that read-only area. You need writable memory associated to the ...
user avatar
  • 20.7k
1 vote
Accepted

PSet 5 Speller Compiles, but Not Producing Output

In your load function, you are created a new_node, adding it to your linked list, and then freeing it free(new_node);. You've just thrown away your node. You shouldn't free your nodes until you ...
user avatar
  • 18.3k
1 vote
Accepted

Problems with hash function in pset5

The code will return index % HASHSIZE;, but where is index calculated? Maybe index was supposed to be hash? If this answers your question, please click on the check mark to accept. Let's keep up on ...
user avatar
  • 63.1k
1 vote

In pset5 is there a preferred place to put the hash function?

Putting actual code into a .h header file is something that should never be done. Any hash function, or any function for that matter, should be in a .c file. In this case, you should be putting your ...
user avatar
  • 63.1k
1 vote
Accepted

Spell-checking segmentation fault

You're right that it is in the load function. The seg fault occurs near the end. previous -> next = new; The problem occurs when you are adding the first word for a given hash index to the ...
user avatar
  • 63.1k

Only top scored, non community-wiki answers of a minimum length are eligible