Questions tagged [cs50]

Code questions pertaining to Harvard's self-study introductory. It is STRONGLY RECOMMENDED to additionally tag with C or Python. Also consider using the spin-off https://cs50.stackexchange.com/

Note there is a spin-off site at https://cs50.stackexchange.com/. Consider joining the community and directing your questions there.


The CS50 (a.k.a. CSCI S-50) courses are computer science courses from Harvard University as part of its edX program.

There is a C library available at CS50 Library which provides support functions for the course.

There is also a Python library at CS50 Library which provides support functions for the course.

The tag should be used primarily for questions also tagged or (though the course does use some other languages too, and if there is a need, the extra languages would be valid too).

This tag should be used for questions which use the "cs50.h" header, python-cs50 or -lcs50 library. Another symptom that it is appropriate is the use of the type string (which is defined with typedef char *string; in the cs50.h header) or functions such as get_char(), get_double(), get_float(), get_string(), get_int(), get_long_long() and SQL().

The term 'pset' with a number (e.g. PSET5 — for Problem Set 5), with varying capitalizations is also often an indication that could be appropriate.

  • As an alternative to edx, there is a standalone website (called CS50x) where all the course materials and problem sets can be found.
  • There is CS50 Stack Exchange site dedicated to the course.
  • You can run CS50 programs in Visual Studio Code for CS50 (Codespaces)
  • The previous CS50 IDE has been deprecated. Use the Codespaces link above instead. For reference, here is the link to the previous CS50 IDE
  • CS50 has a "CS50 Sandbox" to run in a test environment. The CS50 Sandbox will be decommissioned on July 1, 2023. Sandbox URL: http://sandbox.cs50.io/ A suggested alternative after that date is Replit
3444 questions
0
votes
0 answers

CS50 Speller.c Errors

A couple questions here. I'm trying to figure out Week 5 Pset5 Speller. Here is my code: // Implements a dictionary's functionality #include #include #include #include #include #include…
0
votes
1 answer

Why does the code keep choosing the else option

so i'm in quite a bind with the ceaser problem set. I'm trying to confirm if the second command line argument is a number using the if-else statement below and the code keeps on choosing the 'else' option. I've converted the string argument with the…
0
votes
0 answers

CS50 Python & JS Web: Cannot operate website after trying to 'makemigrations'

I have been working through the Web with Python and Django with the CS50 course. When i got to the stage of 'makemigrations' it didnt run and not i cant use the command 'runserver' either. PS C:\Users\44777\code\airline> python3 manage.py runserver…
0
votes
2 answers

Segmentation fault when converting string to upper case

Segmentation fault: could someone help me to understand my mistake? Target: make a new string with only CAPS LETTERS. Also, I am trying to identify letters I do not want by referring to the ASCII table, hopefully, that is the right approach. CS50…
0
votes
0 answers

sqlite3.ProgrammingError: Incorrect number of bindings supplied. Following along CS50

I know there are a lot of questions about this on SO but none of them helped me. I am trying to follow along in the CS50 lecture 9 using sqlite3 instead of their SQL library but keep getting the error: sqlite3.ProgrammingError: Incorrect number of…
VaultDweller
  • 127
  • 1
  • 8
0
votes
1 answer

segmentation fault on CS50 Caesar and debugging

Hey all I asked a question related to this code earlier and got a lot of helpful answers (I'm very green at coding). While I overcame my initial problem and corrected a few more mistakes I've run into another error that I can't seem to fix. I keep…
Quise
  • 7
  • 1
0
votes
2 answers

Django 3.x - Custom Error Page is showing a 500 when it should be a 404

UPDATE: Added the code I was accessing that threw the error For a CS50 project I'm working on with a wiki page, I'm trying to send the right custom 404 error when a user types a page that doesn't exist in wiki/TITLE however when I type a missing…
Los
  • 147
  • 1
  • 11
0
votes
1 answer

Need help accessing Python dictionary value in Jinja using Flask application

Here is my Flask Python application. @app.route("/") @login_required def index(): """Show portfolio of stocks""" holdings = db.execute("SELECT symbol,SUM(shares),price FROM purchases GROUP BY symbol HAVING id = ?",session["user_id"]) …
0
votes
1 answer

Django - Page redirect showing as empty page after saving?

UPDATE: I'm trying to use HttpResponseRedirect() to guide the user back to the entry page but it's not working for me somehow with this syntax: return HttpResponseRedirect((entry_page(request, title)) I'm working through a Wiki project for CS50's…
Los
  • 147
  • 1
  • 11
0
votes
1 answer

CS50 - Lab 2: Scrabble - Error: called object type 'int [26]' is not a function or function pointer scrabble

I've been doing this code; supposed to take words from two different players, calculate the score while using the for loop to go through each character one at a time. I've been re-reading it 1000 times, but it doesn't seem to be helping. I get this…
rbakk
  • 3
  • 1
0
votes
1 answer

Upper case letter input in scrabble game always returns 0

i wrote a code for cs50. My task was to create a scrabble game. everything worked fine with lower case letters but when i tried upper case letter the value the computer returned to me was always the same 0. I tried to fix it on my own but i only…
0
votes
0 answers

CS50 Speller: valgrind test says that bytes are still reachable in 3 blocks

I'm currently at the CS50's pset5, and am working on the "Speller" problem. I managed to do all functions and don't have any compile or runtime errors. When using check50, though, I receive a sad face (:() on the last line, saying: :( program is…
Mateaș Mario
  • 113
  • 1
  • 7
0
votes
1 answer

Error when returning multiple return statements in a Django view, 'tuple' object has no attribute 'get.'| cs50 web project 4 (network)

I am working on CS50 Network and am supposed to design a Twitter-like social network website for making posts and following users. In my view's return statement I am trying to render a page and a jsonrespone. The JsonResponse is so javascript can…
Jeswanth
  • 1
  • 2
0
votes
0 answers

Readability, why won't Coleman-Liau index formula work when I plugin words, letters, and sentences?

whats wrong with my code? this is the part that doest work float L = (letters / words) * 100; and float S = (sentences / words) * 100; when I plug in letters, words, and sentences into the formula it gives the wrong answer. #include…
itzdre96
  • 1
  • 4
0
votes
0 answers

How to fix munmap_chunk(): invalid pointer when calling fclose and overwriting stack variables in C?

For context this code relates to a CS50 assignment that involves loading a bunch of words from a text-file/dictionary #include #include #include #include #include #define LENGTH 10 unsigned int…
pcoppi
  • 23
  • 2
1 2 3
99
100