Hot answers tagged

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 ...
user avatar
  • 3,316
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 ...
user avatar
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). ...
user avatar
  • 293
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 ...
user avatar
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 ...
user avatar
  • 17.4k
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., ...
user avatar
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 :).
user avatar
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://...
user avatar
  • 20.7k
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 = ...
user avatar
  • 17.4k
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 ...
user avatar
  • 3,316
6 votes
Accepted

pset6 (server.c) content length

After your content type line, try adding another \r\n to finish up.
user avatar
  • 18.4k
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., ...
user avatar
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 ...
user avatar
  • 17.4k
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 ...
user avatar
  • 1,424
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 ...
user avatar
  • 3,035
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, ...
user avatar
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 ...
user avatar
  • 17.4k
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] =...
user avatar
  • 17.4k
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 ...
user avatar
  • 18.4k
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 ...
user avatar
  • 7,326
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 ...
user avatar
  • 41
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 ...
user avatar
  • 141
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 ...
user avatar
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 ...
user avatar
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.
user avatar
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 [...
user avatar
  • 20.7k
3 votes

Peeking into large dictionary - Pset6

command line: gedit ~cs50/pset6/dictionaries/large will open it in gedit
user avatar
  • 1,317
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 ...
user avatar
  • 17.4k
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 ...
user avatar
  • 2,625

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