Hot answers tagged

6 votes

Understanding how memory is allocated in driver code PSET 4, Filter (Less Comfortable)?

RGBTRIPLE(*image)[width] means variable image is a pointer to an array of length width of RGBTRIPLE. RGBTRIPLE *image[width] means variable image is an array of width pointers to RGBTRIPLE. The ...
user avatar
  • 20.7k
3 votes
Accepted

What does VALUES(shares) refer to in the ON DUPLICATE KEY UPDATE clause?

According to the docs: You can use the VALUES(col_name) function in the UPDATE clause to refer to column values from the INSERT portion of the INSERT ... ON DUPLICATE KEY UPDATE statement. In ...
user avatar
  • 17.4k
3 votes
Accepted

Why can't I print the entire string from the read file?

I guess you meant print(dna[i:i+len("AGATC")]). In Python, if the end of the substring is before the beginning, the substring is empty, so you are printing a bunch of empty strings.
user avatar
  • 20.7k
3 votes
Accepted

python invalid syntax end=""

I added a space in there and it took the flag away. The rest of the print lines without the space are not flag. I'm wondering if this is a bug with the IDE or am I not understanding something? This ...
user avatar
  • 41
2 votes

MARIO LESS COMFORTABLE

Using the 5 pyramid as a guide: Height: 5          ##        ###      ####  &...
user avatar
2 votes

Understanding how memory is allocated in driver code PSET 4, Filter (Less Comfortable)?

What are the parentheses doing? As Blauelf explained, they are changing order of operations. I didn't full grasp why this was needed though until trying to compile without them. filter.c:78:15: ...
user avatar
  • 61
1 vote

Could someone explain to me how curly braces work?

Curly braces help define scopes (range of allowed operation) for variables and statements in C and some other languages. They also help in defining coding styles. The CS50 course uses a particular ...
user avatar
1 vote

Syntax Highlighting Error

Just a guess, did you open a new file that has yet to be named or saved? Assuming you're in the CS50 IDE, are you writing your code in a file with the .c extension? The IDE has to see that extension ...
user avatar
  • 63.1k
1 vote

php syntax questions

here are two solutions: you could use the string concatenation operator (i.e., .). example: echo "the session id is: " . $_SESSION["id"] . "!"; you could surround the name of the variable with ...
user avatar
  • 17.4k
1 vote
Accepted

cs50 pset7 buy syntax error

I would expect you to have an autoincrementing id field that is the primary key (so each transaction has an id) and then a user_id field that holds the user_id for the transaction (that is not unique)....
user avatar
  • 18.3k
1 vote
Accepted

PSET 6: Caesar.py - stuck on "SyntaxError: invalid syntax"

It is as easy as replacing else with elif, in python a condition is not allowed after an else, remember that else is executed if the if condition is not fulfilled, if we want to impose a new condition ...
user avatar
  • 5,172
1 vote
Accepted

The syntax "<%- place_name %>" in pset8

This is the template syntax used by the Underscore.js JavaScript library. There's a link to the full documentation in the Problem Specification. You may also wish to pay special attention to this ...
user avatar
  • 3,035
1 vote
Accepted

What's is wrong with this php code

echo("</tr>") not properly terminated.
user avatar
1 vote
Accepted

caesar store ascii value as int, in loop

You can just go ahead and treat it as an integer. If, for example, plaintext="bar", plaintext[0]=b=98, and you can just perform operations with it, such as plaintext[0]+1, which will yield 99.
user avatar
  • 1,415

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