Hot answers tagged

5 votes

Problem with query quotes from Yahoo finance

Thank Brenda Anderson from Facebook group CS50 for providing a new code for helpers.py
user avatar
2 votes
Accepted

Pset6 one check50 error

It's a common problem when abs_path and query are built one character at a time. The problem seems to be in parse. abs_path (and query) are not properly null-terminated. So server returns a 404 error ...
user avatar
2 votes
Accepted

Alternative to multiple if statements?

You can refactor your code to use only one if statement! Think about the number of MIME types you have to check for, and the number of matching file extensions. Since there are the same number of ...
user avatar
  • 3,035
2 votes

Problem with query quotes from Yahoo finance

Yahoo finance has killed it's API You can read more about the topic via the Hacker News discussion linked below. https://news.ycombinator.com/item?id=15616880
user avatar
2 votes
Accepted

Is it possible to code lookup function without malloc?

Well, here is the thing: I don't think you really have to allocate memory on the heap at all. Besides, you are never making use of the allocated memory and it is not recommended per the pset ...
user avatar
  • 17.4k
2 votes
Accepted

(PSET6) hello.php always displays hello, hello, world regardless of input?

The "weird" results you report For some reason, if I alter the order in which the file extensions are searched, cat.html suddenly doesn't load. is the "unpredictable results" that happen when ...
user avatar
1 vote
Accepted

Why does my lookup function keep returning "None"?

Since the quote spec calls for an element named "symbol", and this if not request.form.get("stock"): is apparently working, it looks like the element is not named properly in the ...
user avatar
1 vote
Accepted

Pset 9 Finance index function, current stock price not displaying correctly

The problem isn't lookup. The problem is portfolio. There are exactly two keys in the portfolio dictionary, "current_price" and "holding_total". They are set to the values in each ...
user avatar
1 vote
Accepted

Finance index function does not return lookup value in index.html

Each dict in portfolio contains 3 keys as returned from the execute. There is no key current_price, so the html does not render anything for that column. If the key gets created in the for loop in ...
user avatar
1 vote

CS50 Finance lookup function always returns NONE

OK, i am just dumbo, i used my API token without last character
user avatar
1 vote

Scramble.c lookup function found flag

A few things. Valid indexes would probably range from 0 to size-1, and as you chose your interval boundaries as both being part of the interval, your initial interval end should include the -1, to ...
user avatar
  • 20.7k
1 vote
Accepted

PSET7 Finance Question Quote Lookup Page

One problem is here <form action="/quote.html" method="post">. There is not a quote.html in document root (it is in subdir templates), thus the 404. But do you really want the form action to be ...
user avatar
1 vote

scramble lookup function

dictionary contains an array of words and each of those words contain an array of letters. So dictionary.words[0].letters would represent the first word in the dictionary. You're on the right track,...
user avatar
  • 18.3k
1 vote
Accepted

PSET6 Lookup - Read-Only Variable As Well As How to Approach

When you use that keyword const, you're promising your compiler that you won't change the contents of what's inside the array. That's why the compiler yells... because you're trying to change it here ...
user avatar
1 vote
Accepted

Need help with pset6, lookup and parse function!

char* s = strrchr(path, '.'); as I understand strrchr returns a pointer to point '.', hence the string s would be something like ".css" for example, on the other hand strcmp, compares two string, to ...
user avatar
  • 5,172
1 vote

Pset6 check50 server1 parse error

I inserted your program in this parse.c to debug it: #include <stdio.h> #include <string.h> #include <strings.h> #include <cs50.h> #define LimitRequestLine 8190 bool parse(...
user avatar
1 vote

Pset6 check50 server1 parse error

Since there are only two places in server.c that return a 505, and they are both in this parse function, that's a good place to start looking. debug50 or gdb (tips here) would be perfect tools to ...
user avatar
1 vote

pset6 server fails check50

First of all, WOW: your code is awesome. I took LOOKUP on the side and I could not see any obvious errors. I did find some behaviors on PARSE you might find useful. This is how I debugged your ...
user avatar
1 vote

pset6 server fails check50

There are some problems that are quick to see. They are most likely not all the problems in play here. parse The server1 failure probably stems from here strncpy(request, req_pos, (v_pos - req_pos -...
user avatar
1 vote
Accepted

pset6: requesting php from within html isn't working

Since those are the only two tests that fail check50, redirect your attention to how query is built in parse. Since hello.php "works fine", verify that query is properly null-terminated. A helpful ...
user avatar
1 vote
Accepted

Pset6 - check50 missing cat.exe and non-existant file request

strcasecmp is meant for comparing string without caring about capitalization. Comparing twice, with different capitalizations is not really useful here. The reason why you are getting the 505 HTTP ...
user avatar
  • 309
1 vote
Accepted

Problem with check50 for server1

There's only one place that server returns a 505, and that is from your parse function. Your server is never even getting to lookup. This guy if (strcmp(word, "HTTP/1.1") != 0) is always evaluating to ...
user avatar
1 vote
Accepted

Why Pset6 check cat.exe and non-existant file going wrong?

First suggest you send a request to server from browser or curl. You will discover that server seg faults. (That's what this \ expected output, not an exit code of 0 feedback from check50 indicates). ...
user avatar
1 vote
Accepted

pset 6 server - Load produces inconsistent results

for (char read = fgetc(file); read != EOF; read = fgetc(file)). read cannot be a char. Because of internal casting in fgetc, this can return a "false eof", and almost always does on binary (image) ...
user avatar
1 vote
Accepted

PSET6 check50 server1 cat.exe and non-existant file return error 505

server should return 505 in exactly one place, from the parse function http version check. That means that strcmp(HTTP_version, "HTTP/1.1") does not return 0. That means that HTTP_version is not "HTTP/...
user avatar
1 vote
Accepted

pset6 server.c 403 forbidden for "/", problems for lookup and indexes

Hint: This line in indexes if (access(phpcheck, F_OK)) (and the other access) is wrong. Suggestion: Read man access. Pay special attention to the RETURN section. access returns an int. Treat it like ...
user avatar
1 vote
Accepted

Pset6 server.c Error 403

strcpy(s,lookup(line)); After gdb: Program received signal SIGSEGV, Segmentation fault. __strcpy_ssse3 () at ../sysdeps/i386/i686/multiarch/strcpy-ssse3.S:84 I would look for another way, ...
user avatar
  • 5,172
1 vote

first version of check50 not working pset6

All things being equal, the only place that server returns a 505 is the parse function. If this parse function reaches for(int i=0;i<strlen(line);i++), it will always return a 505. Howzat? Assuming ...
user avatar
1 vote

Bug in the pset7 distribution code Lookup

Should be: if ($data[1] === "N/A") {...} $data[2] returns 0 if the symbol is invalid. Otherwise, yup, what you said. (Honestly, this will probably be a moving target over time.)
user avatar

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