Skip to main content
4 votes
Accepted

Compilation error in hello.c: undefined reference to `get_string'

Compiler does not complain about missing cs50.h, so that looks right. The linker does complain, though, and that's probably because you did not pass -lcs50 when compiling (telling the linker to ...
Blauelf's user avatar
  • 21k
2 votes

Can't compile readability in cs50 IDE

I found that when following the instructions to create readability, the newly created tab "readability.c" has a red dot, and when clicked, it prompted me to save. Once saved, it should work. Hope ...
dragoogm's user avatar
2 votes
Accepted

cs50 make mario Hello I'm new to cs50 course when doing make mario i got this error

This is a very, very basic mistake, but something you'll instantly learn not to repeat. The C language is case sensitive. while is the keyword that should be used, but While is unacceptable. Note the ...
Cliff B's user avatar
  • 69k
2 votes
Accepted

pset 3 plurality code help

for (int i = 0; i < candidate_count; i++) { if (candidates[i].votes >= maxvote) { maxvote = candidates[i].votes; winner = candidates[i].name; ...
Ojou Nii's user avatar
  • 731
1 vote
Accepted

cs50 - prime: compiling error understanding

This is a common error. First, remember that compilers are dumb but thorough. It found a path through the prime function that doesn't produce a return value. Here's what the compiler sees. If the ...
Cliff B's user avatar
  • 69k
1 vote

check50 error message when testing test_fuel.py

The test that is failing is NOT importing YOUR fuel.py. It is testing YOUR test_fuel.py against the check50 test version of fuel.py (called the "correct fuel.py" in the link). That way ...
kcw78's user avatar
  • 837
1 vote

pset 3 plurality code help

Your code is incrementing maxvote every time your if statement is true.. The goal is to get the max number of votes and see then check if who are the candidates that have the same number of votes to ...
Ojou Nii's user avatar
  • 731
1 vote

PSet1 - Coins issue

You also have the problem that it will always produce 0 as a result because of this: return 0; Instead, it should return quarter; That still leaves the problem of leaving the correct amount of ...
Cliff B's user avatar
  • 69k
1 vote

PSet1 - Coins issue

There's a semi-colon after your for loop, so it's simply ignoring the body. Remove that and you should be good. You can do this without a loop. Think about how you would approach this if you were to ...
Fuelled_By_Coffee's user avatar
1 vote

incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int'

The function atoi returns an integer. You're assigning it to a variable of type char *. Change it to int key to fix.
Fuelled_By_Coffee's user avatar
1 vote
Accepted

pset1 mario (less comfortable), expression error

you have an error in the following loop: for (d = 7-r; d >= 0; d-) I guess you want to write: for (d = 7-r; d >= 0; d--)
MARS's user avatar
  • 5,169
1 vote
Accepted

PSET5 Compiling issue

Review carefully man strcasecmp: NAME strcasecmp, strncasecmp - compare two strings ignoring case SYNOPSIS #include <strings.h> It is not in the string.h library. This error invalid operands ...
DinoCoderSaurus's user avatar
1 vote
Accepted

initializer element is not a compile-time constant and expected identifier or '(' errors

Along with GetInt being updated to get_int, where is the following structure? int main(void) { //all the program code } This is not a complete program and the compiler thinks that you're trying ...
Cliff B's user avatar
  • 69k
1 vote

scores2 keep giving error even after copying the code verbatim from CS50 2018

The whole problem lies in the semicolon after the declaration of the for loop: for (int i = 0; i < COUNT; i++); The semicolon indicates to the compiler that the for loop ends, before starting, so ...
MARS's user avatar
  • 5,169
1 vote
Accepted

Cannot Compile Due to Error in cs50.h

The function signature has changed. From the CS50 Programmer's Manual char *get_string (const char *format, ...); DESCRIPTION Prompts user for a line of text from standard input and ...
DinoCoderSaurus's user avatar
1 vote
Accepted

PSET2 Vigenere: Control may reach end of non-void function error

You're right. The compiler just knows that there's a possibility of getting to the end of the code without seeing a return statement, so it's unhappy. However, your fix in the comments has a flaw. ...
Cliff B's user avatar
  • 69k
1 vote

Keep getting this compile-time message: error: unused parameter 'argv' [-Werror,-Wunused-parameter]

int key = atoi("argv[1]"); this is using the literal string "argv[1]", not the value stored in argv[1]. Also, you should be checking that argv[1] exists before you use it as an argument to atoi (ie,...
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

Keep getting this compile-time message: error: unused parameter 'argv' [-Werror,-Wunused-parameter]

Actually, no, you're not using argv[1]. int key = atoi("argv[1]"); By putting it in double quotes like that, you're telling the code to use the literal string "argv[1]" instead of the var. It ...
Cliff B's user avatar
  • 69k
1 vote
Accepted

Pset3 - Music: Unused parameters and control reaches end of non-void function errors

There are a few simple issues. First, octave is being declared and then redeclared, but, amusingly, that isn't the actual problem. The real problem is that they are being declared inside of code ...
Cliff B's user avatar
  • 69k
1 vote
Accepted

PS3's Fifteen won't compile only during check50?

check50 for fifteen replaces the draw function with a simple one whose output is then used for the tests. If your own draw function contains code (setting the values of global variables or calling ...
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

strange error message when compiling helpers.c

no function main () in helpers, hence the error when compiling, you only have to type make in the terminal, if you are located in the appropriate directory, by the way the swap function will not work, ...
MARS's user avatar
  • 5,169
1 vote
Accepted

What does "using" a variable entail and why does this inconsistency come up? (pset1, greedy, general question)

The root of this problem lies in the order of operations. In C, postfix increment (++) binds more tightly than dereference (*). Thus, what the code *coins++; does is not to dereference coins and then ...
Levi Roth's user avatar
  • 188
1 vote

pset1 - Greedy Errors "error: expected expression"

The error is created by the compiler finding an else clause without knowing the corresponding if (there has to be exactly one statement or code block in between). Use {} blocks with your if to ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

Subscripted value is not an array

The variable a is declared as a single integer. In the line if (a > a[y+1]) this code attempts to compare a to an array of the same variable name. This presents two problems. First, two vars can't ...
Cliff B's user avatar
  • 69k

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