3 votes
Accepted

Should We Free Memory Allocated By GetString()?

Short answer: yes! Long answer: looking at the code of GetString() string GetString(void) { // growable buffer for chars string buffer = NULL; // capacity of buffer unsigned int ...
user avatar
  • 17.4k
3 votes

In "cough-4," is it better to define 3 functions or 1 function?

Pay attention to the end of the video, where Prof. Malan explains the purpose of user-defined functions: ... as our programs get much more complicated, and our programs more sophisticated, this ...
user avatar
  • 2,136
3 votes

What does if (s != NULL) do?

So what actually this condition does? this condition basically tests whether the char pointer (aka a string) s points to nothing (i.e., address 0x0 in the computer's memory) which is the address of a ...
user avatar
  • 17.4k
2 votes
Accepted

For week 4 walkthrough unused variable even though I typed the same code as David

Actually, it's not really anything to do with the code you've typed in. Its the clang compiler complaining. The breakout.c program would also suffer the same fate if clang was not told to suppress ...
user avatar
2 votes
Accepted

Should I Watch the Sections and Walkthroughs?

Absolutely - of course! If you're kind of new to CS you'll realise why very quickly. You'll also find technical help (only) here and technical, practical and moral support help on the CS50 Facebook ...
user avatar
  • 151
2 votes
Accepted

Trying to compile f2c.c from walkthrough week1 without success

You are in the wrong directory, change the directory to where your file is stored i.e. Desktop here jharvard@appliance (~) : cd ~/Desktop jharvard@appliance (~) : make f2c jharvard@appliance (~) : ./...
user avatar
  • 3,316
2 votes

Subtitle files for problem set 0 videos

If you're using edx, the videos posted on there have subtitles. Go to Week 0 > Shorts (or click here) and click one of the options on the top bar. I don't see the fourth video listed, however. ...
user avatar
  • 481
1 vote

What does if (s != NULL) do?

Here's the GetString documentation that David is referencing in that lecture, from the CS50 library 3.0: /* * Reads a line of text from standard input and returns it as a * string (char *), sans ...
user avatar
  • 2,136
1 vote

Multithreading vs. Multiprogramming

Hmmm.... I disagree with the other answer, at least somewhat. Multithreading is when a single program actually runs more than one process in parallel. That program is actually written with multiple ...
user avatar
  • 63.4k
1 vote
Accepted

Walkthrough 'text' why is pressing enter needed

According to SPL's documentation about GTextField GTextField GTextField(int nChars); Creates a text field capable of holding nChars characters. Assigning an action command to the text ...
user avatar
  • 7,326
1 vote
Accepted

Week 1 - Conditions - error expression result unused (expect ; at end of if else)

The if/else if/else conditions are used in the following way: Single condition if (condition) { // code to execute } Double condition if (condition) { // code to execute } else { // ...
user avatar
  • 7,326
1 vote

Week 1 - Conditions - error expression result unused (expect ; at end of if else)

else is your last resort kind of command its like if this then { do this } or else if this then { do that } and finally when you cant think of any other condition you say you know what MR ...
user avatar
1 vote
Accepted

F2C Walkthrough Week1, What is wrong with my code?

The short version is that you shouldn't expect an executable compiled for one version of Linux to work on another. The simple explanation is that because of all the variations between all the ...
user avatar
  • 63.4k
1 vote
Accepted

How to run button.c and other programms?

When you issue the command make bounce in a terminal window, it will usually do one of two things - it will either try to make the executable file 'bounce' from the source file 'bounce.c' or it will ...
1 vote

week 4 | walkthroughs | bounce | compiler error

I took this off the video and it worked for me: clang -ggdb3 -Ispl/include -O0 -std=c99 -o bounce bounce.c -Lspl/lib -lcs -lm Note the bits about spl after -ggdb3 and before -lcs.
user avatar
1 vote

week 2 - walkthroughs - ages.c: average

Figured it out. sizeof gives the size in bytes. simple fix: sizeof(arr)/sizeof(arr[0]) gives the number of elements in the array.
user avatar
  • 63
1 vote
Accepted

week 4 walkthrough swap

Remember that parameters in function call should pass the address of variables like swap(&p, &q); Ideone int tmp = *a; The value stored at the memory block to which a was pointing, is being ...
user avatar
  • 3,316
1 vote

"No playable video sources found" when trying to watch cough-1

All the course resources can be found on the course's website and the Youtube channel too! Here's cough-1 from week 0!
user avatar
  • 17.4k
1 vote

In "cough-4," is it better to define 3 functions or 1 function?

Computer science is all about problem solving. And there are usually many solutions to a single problem. Yes we could have used a single custom block, passed "cough" or "sneeze" and the number of ...
user avatar
  • 17.4k

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