Questions tagged [pset6]

The problem set for Week 7

Filter by
Sorted by
Tagged with
0
votes
1answer
214 views

Malloc call placement interfering with strtok function?

I am currently working on verifying and dissecting the request line for pset6 server. I decided to make a smaller test program to explore some of the methods to extract the request, path, query, etc. ...
0
votes
0answers
188 views

Problem using a function to manipulate strings in pset6 server

This given code in server.c gets the slice of string up to an appearance of \n. const char* haystack = request; char* needle = strstr(haystack, "\r\n"); if (needle == NULL) { ...
0
votes
2answers
604 views

Variable optimized out eventhough it will be used later

When trying to debug my implementation of server.c, asking gdb to print out the variable line results in a <optimized out>. (gdb) p line (gdb) <optimized out> After doing a bit of ...
2
votes
1answer
249 views

"subtraction" of string in pset6 server.c

In server.c in pset6, there is a line of code where a string is "subtracted" from a string. I tried to find out what this operation does by writing a simple program : char* needle = "needle"; ...
1
vote
1answer
604 views

cat.jpg not displaying in cat.html

I've gotten all functions of server.c to work, including displaying hello.html successfully. However, when I attempt to access cat.html, program is not displaying the image. The chrome developer ...
0
votes
1answer
487 views

Two questions about "respond to client(browser)"

In pset6(server.c), when responding to client(browser), we use the function "dprintf", but why do we put the "dprintf" in the "if" ocndition, and call "continue" when "dprintf" fails? What is the ...
1
vote
1answer
801 views

problems about "respond to client" and "concatenate root and absolute-path" in server.c

What does "respond to client" mean? What should I do to respond to a browser? And, should I use "printf" to print out the response? Another problem is, when I refresh the browser, my program ...
2
votes
1answer
240 views

To ensure the file is readable

In pset6, server.c, what should I do to make sure the file is readable? the problem set guide says it's possible to use "stat" or "access"? since both return 0 on success and -1 if not, how do I ...
0
votes
1answer
977 views

Pset6 Web Server, need help with respond to client and some others

I've been slowly working through this problem set for a couple weeks now, and I think I've hit a brick wall. Giving just a general overview, I believe at this point that I have successfully completed: ...
0
votes
2answers
519 views

pset6 dictionary.c Why am I getting a segmentation fault loading the large dictionary

My program works fine with the small dictionary. But when I attempt to load the large library it gets a segmentation fault when loading the 1908th dictionary word. The code that I am using is below. I'...
0
votes
1answer
656 views

pset6 (server.c) content length

I am repeatedly getting ERR_CONTENT_LENGTH_MISMATCH in Chrome's Network Status tab when trying to load any file in the appliance's browser. This is despite the content loading correctly when I run it ...
0
votes
0answers
589 views

pset6 (server.c) strcpy and pointer behaviour

I have come across an interesting little problem in server.c which I hope someone could explain so I can learn from it please. I have been happily defining substrings from the request-line using ...
1
vote
0answers
976 views

How to run my copy of server.c

I am sure this is a stupid question, but I am struggling to workout how I actually run my version of server.c in pset6. Do I need to compile it? Whenever I try and "make" the file, terminal reports ...
0
votes
0answers
394 views

pset 6, server.c, query sent but hello.php doesn't receive it

Although the spec does not mention to handle .php files, I found that if I do not have my lookup function return "text/html" when it receives a .php extension, then I get a 501 Not Implemented error. ...
7
votes
1answer
1k views

having trouble validating request line in server.c

My main issue is doing this without using the heap, I think. I set up arrays for each of the pieces of the request-line (e.g. method, request-target, etc.) and set all of them to be of length = strlen(...
1
vote
2answers
436 views

Can not run staff solution of server.c

I am trying to run the staff solution of server.c but I get an error that I need to install rsplib=legacy-wrappers. What does it mean? I just updated the appliance and restarted it, but problem is ...
1
vote
1answer
485 views

Segmentation Fault in pset6 (speller)

When running a finished speller, I receive an unhelpful segmentation fault. jharvard@appliance (~/Desktop/pset6): ./speller ~cs50/pset6/texts/austinpowers.txt Segmentation fault (core dumped) ...
0
votes
1answer
107 views

why check50 is not evaluating corectly for my question

I have tried to approach the question in move simplifir=ed way and i have created an array and declared it globally. my programme is correctly responding to all the asked questions but still I'm not ...
0
votes
2answers
234 views

Pset6 "Size" giving the wrong output

I am counting one word too many every time my dictionary loads, what could be the cause? I initialize the variable 'word_count' here: bool load(const char* dictionary) { // Open the "dictionary"...
0
votes
1answer
129 views

Why check50 is not evaluating true when my programme is corectly responding to all the asked questions?

When i run check50 it shows everything in red and when i open the given link it shows the below image. I have removed the printf commands also but still then it is showing the same problem. someone ...
0
votes
2answers
325 views

Test program compiles with <math.h>, speller.c shows error

I've edited the pset6 Makefile to include all headers, and was careful not to edit any spaces or tabs. When I try to compile speller, I get the following error: make: *** No rule to make target `math....
1
vote
1answer
2k views

Dynamic string length allocation in new_node->word; array type char [46] is not assignable

I am trying to make my node size dynamically change with the size of the word from the dictionary in the load(dictionary) function. I understand that the warning means I am trying to assign a pointer ...
0
votes
1answer
309 views

Am I creating an array of pointers or an array of structs?

I've read an answer to a similar question about node* new_node = malloc(sizeof(node)); and how it allocates memory for the pointer plus all the data contained within the struct as it was declared ...
1
vote
1answer
771 views

Pset6: Is it possible implement a 3D Hash table Matrix?

It might be too early on for me to ask questions in this problem set, as I am just getting started with load. I was looking up Hash Functions, and they look a little cryptic to me. Is it possible to ...
0
votes
1answer
86 views

PSET6: Load segfaults when I try to access variable in node

The relevant snippet of my load function: FILE* dict = fopen(dictionary, "r"); bool complete = true; for (int c = fgetc(dict); c != EOF; c = fgetc(dict)) { node* head = malloc(...
-1
votes
2answers
69 views

Initializing struct globally in pset6: trouble with persistent values of root

I'm implementing a trie for pset6. load works properly as far as I can tell. (gdb, valgrind both fine with it, and the #of words loaded comes out right as well). check, however, generates a ...
0
votes
2answers
1k views

Could not load dictionary in cs50 pset6

I have written the load code for pset6 which compiles but when I execute speller.c it returns "Could not load dictionary". I have tried using a homemade dictionary on my machine and the dictionary at ...
1
vote
1answer
36 views

Declaring and Using an argument in a while loop

I would like to make new nodes and then use it in an argument in my while loop. However, I can't figure out how to do this in an order which makes sense: while (fscanf(dictptr, "%s", n->word)==1) ...
0
votes
1answer
455 views

linker fails with exit code 1 in pset6

Why am I getting the following error message when I try to compile and how do I get rid of it? jharvard@appliance (~/Dropbox/pset6): make dictionary clang -ggdb3 -O0 -Qunused-arguments -std=c99 -...
0
votes
1answer
162 views

why my pset6 got zero? Everything worked fine when I compared my solution with the stuff and check50

I submitted my solution to PSET6, but the autograder does not seem to evaluate the solution correctly. I have checked the solution using check50 and everything passed. I compared the staff solution ...
0
votes
0answers
249 views

pset6 check function - student result set doesnt match staff - works on small test, fails on big

I have a version of dictionary.c that has all of the functions completed and compiling. When I run ./speller on my small test sets it completes succesfully. When I run it using the following test, ...
0
votes
1answer
154 views

trie does not assign pointers correctly in load and produces seg fault

I ran speller through gdb and keep getting seg fault at if(ptr->children[position] == NULL). I can't figure out why. It works when I use !ptr instead though. Another problem I encounter is that the ...
1
vote
2answers
218 views

unable to load small dictionary

I'm starting on pset6 and planning to use a trie to load the dictionary. I wrote a little code and wanted to test it as follows but it did not print the correct words. The test was done with the small ...
-1
votes
1answer
294 views

Problem with Handles most basic words properly

When I try to check my pset6 I don't pass two of them https://sandbox.cs50.net/checks/5e81cae19025464a9a188d512fe92923 I think that my problem is in the check function, but I don't understand why ...
0
votes
1answer
323 views

node* root in trie

I'm currently on pset6 and I'm thinking of using a trie to store the words from the dictionary we're given. typedef struct node { bool is_word struct node* children[27]; } node; ...
0
votes
2answers
323 views

Segmentation fault in `load` function of pset6

When I try to run my program, a segmentation fault results. I don't think I am accessing memory that I am not supposed to. Is my code fundamentally wrong? bool load(const char* dictionary) { FILE*...
0
votes
1answer
186 views

pset 6 memory leaks

enter preformatted text hereSpeller works but valgrind says I'm having memory leaks: 52 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==1454== at 0x4029F6F: malloc (vg_replace_malloc....
0
votes
1answer
33 views

In pset 6 can I rename dictionary.c to test if speller.c compiles?

I've written dictionary code using the dictionary.c template given in pset6. I named my code mydictionary.c. Should I be able to make ./speller call mydictionary rather than dictionary to ...
5
votes
1answer
2k views

Please explain char* dictionary = (argc == 3) ? argv[1] : DICTIONARY; from speller.c

I am not sure if I understand what this piece of code in speller.c is trying to accomplish. char* dictionary = (argc == 3) ? argv[1] : DICTIONARY;
1
vote
2answers
154 views

Should my pset6 code be quite long?

Are satisfactory solutions to pset6 really long compared with solutions to previous psets (at least several hundred lines, ex comments)? If not, I'm barking up multiple wrong trees and need to hit ...
0
votes
1answer
241 views

What might be wrong with this pset6 load hash function?

I'd like to use (with attribution) in my "load" section a hash function that I found online. When I try to compile it with Make, I get this: jharvard@appliance (~/Dropbox/pset6): make loadcbook ...
1
vote
1answer
439 views

malloc an array - hash table - Pset 6

Initially i had no problems implementing my hash table during the load function. however when it came time to check for errors, i couldn't access my hash table in order to traverse my linked list. I ...
0
votes
1answer
397 views

Implementing unload() in pset6 for trie

I've been struggling with freeing the nodes in pset6 for the past week. All other functions are completely ok. This is my implementation of node: typedef struct node { bool is_word; struct ...
0
votes
1answer
176 views

Valgrind segfaults, programm doesn´t

I got problems implementing the trie-version of pset6. Since I even got problems to identify the problem, I´m going to ask some questions during my elaboration. Here is what what Valgrinds put out: ...
1
vote
1answer
69 views

Dictionaries are not where they are supposed to be

I've returned to CS50 work after a work-required hiatus. I'm working on pset6 but am having a problem with the location of the dictionaries. I've done update50. I've verified that $HOME and echo ~ ...
0
votes
1answer
941 views

load function in dictionary.c

Checking........................................................................:) dictionary.c, dictionary.h, Makefile exist :) speller compiles :( handles most basic words properly \ expected ...
0
votes
2answers
715 views

How can i make the hashtable global?

I got following problem: Since multiple functions in dictionary.c need access to the hashtable, it should be global. Logical. But my problem is since I want the best possible result (timewise) and ...
0
votes
1answer
84 views

Re-Submitting CS50 projects [duplicate]

For pset 6, I had finished everything else, and then realized that it (the speller) needed to be case-insensitive. I made the change and submitted without testing, confident that there were no bugs in ...
-1
votes
1answer
455 views

Different methods for transforming a string to lower case in C

In the check() function I've figured that I should transform the input word to all lower case. To do that I wrote this: int wlen = strlen(word); char word1[wlen+1]; //transform the word to all ...
0
votes
2answers
391 views

pset6-unload free() : invalid pointer

i get everything working but the unload function, there seems to be something wrong with free() here' the code: void freeChild(node* curr) { if(curr == NULL) return; for(int i = 0; i &...