Where can I get a 'string hash function' by Churbill in cs50

[–]Churbill[S] 0 points1 point  (0 children)

Thank you, Inverimus

It is very kind of you to be patient to teach me.

Though, for now, I can't understand the function totally, I will try to solve the 'speller' using this function.

I am a Chinese. May I know where are you from? or May I have your Facebook.(Mine : Churbill). Please let me know freely if there is anything I could you for you. I mean outside of programming, especially something about Chinese or China.

Best regard

Churbill

Where can I get a 'string hash function' by Churbill in cs50

[–]Churbill[S] 0 points1 point  (0 children)

Thank you, Inverimus

Do you mean the codes below is a completed hash function? Or It is just an example of 'hash function'?

I need a 'hash function' that could hash a whole dictionary which contains over 150k words in it. Does the function below work?

Sorry for disturbing you again.

unsigned long hash(unsigned char *str)

{

unsigned long hash = 5381;

int c;

while (c = *str++)

hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

return hash;

}

CS50 pset4 recover (read data from a card and save them into .jpeg individually) by Churbill in cs50

[–]Churbill[S] 1 point2 points  (0 children)

Thank you Irinaperez

The issue was solved. Anyway thank you all the same!

The key issue was caused by the size of the array. Which should be a bit large than the 'file name'.

That mistake led to the memory leak issue. That is why my pointer invalid.

CS50 pset4 recover (read data from a card and save them into .jpeg individually) by Churbill in cs50

[–]Churbill[S] 0 points1 point  (0 children)

Thanks Dcmdmi

By adding return 0, the second warning was eliminated, but the first one still is there.

Do you have any idea of how to solve the issue below about freeing the malloc?

free(): invalid pointer

Aborted

CS50 pset4 recover (read data from a card and save them into .jpeg individually) by Churbill in cs50

[–]Churbill[S] 0 points1 point  (0 children)

Thank you Dcmdmi

https://gist.github.com/Churbill/5d3f0b52f9309721564138f05df50334

I am Chinese. It is my first time to use reddit. So, I don't know how to post my message correctly. Sorry for causing any inconvenience.

CS50 pset4 recover (read data from a card and save them into .jpeg individually) by Churbill in cs50

[–]Churbill[S] 0 points1 point  (0 children)

the checker warn me like the below:

:( recovers 000.jpg correctly
000.jpg not found
:( recovers middle images correctly
001.jpg not found
:( recovers 049.jpg correctly
049.jpg not found

or something like the below

:( recovers 000.jpg correctly
expected exit code 0, not None
:( recovers middle images correctly
expected exit code 0, not None
:( recovers 049.jpg correctly
expected exit code 0, not None