17-Nov-2021
- For Load part, first problem solved:
FILE* dict = fopen(const char *dictionary, “r”) ← const char *dictionary is equal to string ************
2. what is fscanf and what is the difference between fscanf and fgets
- fscanf will stop scanning once it reaches blank space
- fgets will not stop when it reaches blank space and it will store blank spaces
- how to use fscanf
fscanf(read file pointer, format of how to read the file eg (%s, %c, %i), where to store that data)
Reference: http://tw.gitbook.net/c_standard_library/c_function_fscanf.html
3. I have met this before but always keep forgetting, file could be checked as finished or not by (pointer != NULL) instead of (pointer != EOF)
EOF is the term we use instead of computer use.
4. Should creating new node be including in the loop → I think yes, as the word keeps updating and the word should be placed into hash table before scanning the next one
5. did I misunderstood or is it
char word[] = string = char* word = *word???
or is that if char word[], then I simply ask for word would be enough?
Hash function
What is << in the function?
it means by left shifting the binary number by the second number.
For example, if N << 3, and N = 22. the number 22 would times 2³ to get the left shifted 3 binary number, which is 176 .
You may understand it using decimal base of why it is product instead of sum. Use N=22, N << 3 as example,, but this time is using decimal as base, if I want to shift 22 into 22000, I will time 22 with 10³ instead of add them tgt. https://www.tutorialspoint.com/cprogramming/c_bitwise_operators.htm
5. dont forget to close file pointer
6. Don’t forget to free the hash table list for hash code