32
votes
Accepted
Please explain char* dictionary = (argc == 3) ? argv[1] : DICTIONARY; from speller.c
Assuming you know how a Ternary Operator works, lets visualize the above statement as an assignment statement.
char* dictionary = ((argc == 3) ? argv[1] : DICTIONARY);
It simply assigns a ...
15
votes
Why use fgetc instead of fscanf?
fscanf() should be okay for reading in from the dictionary file, because the words are all separated by line returns. But, fscanf() could cause problems if used to read in from the text file because ...
12
votes
having trouble validating request line in server.c
I have come up with my own solution after doing some research on pointer math.
I used the strchr command to find the first single space in the line (handling a 400 error if that could not be found). ...
8
votes
Accepted
PSET6 (web server): load function giving segmentation fault
That error message is coming from free(content); later in the code. See this post. Specifically (from answer 1, emphasis added):
This happens when the pointer passed to free() is not valid or has ...
7
votes
Accepted
not fully understanding dynamically sized array in server.c pest
of course needle and haystack both are pointers and thus they both store addresses which are essentially numbers so we can perform arithmetic operations on them.
needle - haystack + 2 + 1
subtracts ...
7
votes
Accepted
Instance of 'Analyzer' has no 'tokenizer' member
You don't have a "thing" named tokenizer. Review the hints section of the spec:
Odds are you’ll find nltk.tokenize.casual.TweetTokenizer of interest,
which can be used to tokenize a tweet (i.e., ...
7
votes
Accepted
IndexError in initial state of pset6 Sentiments
This command pip3 install --user -r requirements.txt --upgrade solves the problem according to this post on reddit (and the comments here :).
7
votes
Accepted
pset6 - caesar - check50 error: "expected exit code 1, not 0"
main in Python no longer has a special meaning, but is a regular function, its name only chosen to conform to conventions based in C.
Try exit(1) instead of return 1.
Relevant python docs: https://...
6
votes
Accepted
implementation of hash table
Assuming you're reading the word correctly into new_node -> word and looking at the insertion part of your code
if (hashtable[hashvalue]->next == NULL)
hashtable[hashvalue]->next = ...
6
votes
Accepted
char* text = (argc == 3) ? argv[2] : argv[1];
Yes, you are correct.
char* text = (argc == 3) ? argv[2] : argv[1];
actually means
char* text = ((argc == 3) ? argv[2] : argv[1]);
i.e. assign some value to char *text with the help of Ternary ...
6
votes
Accepted
pset6 (server.c) content length
After your content type line, try adding another \r\n to finish up.
6
votes
Accepted
pset6 python bleep
Is the problem that you have hardcoded the input file to "banned.txt"?
From the specification:
Accepts as its sole command-line argument the name (or path) of a
dictionary of banned words (i.e., ...
5
votes
Accepted
Why use fgetc instead of fscanf?
If you remember from previous weeks, fscanf() by itself is actually not the best function to use to get input specifically strings.
fgetc() reads character-by-character from a stream. This will ...
5
votes
How to start with load function in server.c?
When I hit my road block here, I went back to the source code and re-watched the walkthrough videos, specifically this one: https://www.youtube.com/watch?v=OnAItxJhS70
There are subtle hints ...
5
votes
Accepted
PSET 6 Keeps Stopping Server
The Stopping server message comes from the stop() function defined here:
/**
* Stop server, deallocating any resources.
*/
void stop(void)
{
// preserve errno across this function's library ...
5
votes
Accepted
pset6 tweets, analyze.py and application.py
Maybe a simple typo in tweets here score = analyzer.analyze(tweets), since you want to send one tweet at a time.
Also, beware here: token.lower(). The lower method returns the string in lower case, ...
4
votes
Accepted
PSET6: Sorted List?
If we're NOT using a sorted linked-list, then every time we search for a node in that list, we have to traverse through the whole list in the worst case (if the node we're searching for is the last ...
4
votes
Accepted
valgrind messages about "unititialised value(s)" - are they an issue?
You're totally correct. You have to initialize variables before asking for their values.
Since a trie is an array of arrays, the root array can be initialized when declared like that
node *root[26] =...
4
votes
my server pset throws up "505 HTTP Version Not Supported" but i think it should not
First, recall what the spec says about the request-line:
Per 3.1.1 of https://www.rfc-editor.org/rfc/rfc7230, a request-line is
defined as
method SP request-target SP HTTP-version CRLF
wherein SP ...
4
votes
Accepted
Pset 6 Web Server
Don't look at it like a mountain and get so overwhelmed. It's just another pset, maybe a little more difficult than the previous ones.
Start from the beginning, watch all the lectures and short ...
4
votes
how to close port 8080?
As far as i can tell you can either use another port than 8080 or better stop the server using that port. The command for the latter is:
apache50 stop
This is somehow not written in the pset6 ...
4
votes
Help with .php files in Pset6 -> Load
You want function load() to work for both:
files that have been opened by fopen()
pipes that have been opened by popen()
I also did not manage to make it work by using fseek
I solved the problem ...
4
votes
Accepted
PSET6 Server - Parse function (requesting two files in a row)
I just completed this pset successfully.. I had the same issue and i moved on implementing the next function because if you see in the sandbox link you will find under that error written TODO..which ...
4
votes
Accepted
Pset6 load returns length zero for php files
You would need to use debug50 or gdb to "stop the program and inspect", not check50.
Since you are asking for help with debugging, my comments are intentionally cryptic.
If load returns false, you ...
4
votes
Error in pset6 API Key not set
Make sure you're running flask in the same terminal window in which you exported the keys.
4
votes
pset6 - Similarities: compare has error receiving lists
Not knowing this problem (regular CS50 without x?), I can tell you what the code does.
results = list(set(alist) & set(blist))
turns the intersection of those two sets into a list.
return [...
3
votes
Peeking into large dictionary - Pset6
command line:
gedit ~cs50/pset6/dictionaries/large
will open it in gedit
3
votes
Accepted
segfault while freeing memory in speller
You have to keep in mind that a node is only accessible through a previous node when dealing with a singly-linked-list.
Also, since you've allocated memory separately for the string named word which ...
3
votes
Speller works perfectly but check50 shows the error: "\ expected output, but not '\nMISSPELLED WORDS\nThe\nquick\nbrown...'"
Per a comment by the OP:
I figured out what was going wrong, my check function didn't check
input with the last word in each hash, since it stopped when
pntr->next = NULL.
3
votes
pset 6: Problems using GDB with speller
gdb ./speller ~cs50/pset6/texts/austinpowers.txt
When you run GDB by passing two parameters like this, the second parameter is interpreted by GDB to mean a 'core dump' file, which is not what you ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pset6 × 845server × 212
python × 102
load × 89
parse × 86
dna × 67
check50 × 56
similarities × 45
indexes × 43
cs50x × 29
error × 24
speller × 23
lookup × 23
mario × 19
segmentation-fault × 18
sentiments × 18
webserver × 18
pset6python × 16
analyzer × 16
check × 14
pset6-dna × 14
caesar × 13
pset6-sentiments × 13
c × 11
tweets × 11