Hot answers tagged

2 votes
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 ...
DinoCoderSaurus's user avatar
1 vote
Accepted

PSet5 Speller: Are we hashing the words in the dictionary into a hash table or the words of the text?

the purpose of the hash function is to calculate a hash value for a given word and return that value. Nothing more. The table[] array (or whatever you name it) is an array of pointers to the first ...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

PSET5 - 3 conceptual questions (debug not needed)

Q1: Is it possible? Yes, if you have software specializing in decription. Simple hash functions like encoding the first letter would be easy for systems designed to decode. Highly complex hashes? ...
Cliff B's user avatar
  • 68.1k
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 ...
Cliff B's user avatar
  • 68.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 ...
Cliff B's user avatar
  • 68.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 ...
Blauelf's user avatar
  • 20.9k
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 ...
MARS's user avatar
  • 5,159
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 ...
O1G's user avatar
  • 31
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 ...
Blauelf's user avatar
  • 20.9k
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 ...
curiouskiwi's user avatar
  • 18.6k
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 ...
Cliff B's user avatar
  • 68.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 ...
Cliff B's user avatar
  • 68.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 ...
Cliff B's user avatar
  • 68.1k

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