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 ...
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 ...
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 ...
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;
...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
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--)
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 ...
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 ...
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 ...
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 ...
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. ...
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,...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
compilation-error × 64pset3 × 9
pset1 × 9
cs50x × 8
mario × 7
error × 6
c × 5
clang × 5
pset5 × 4
speller × 4
greedy × 4
function × 4
pset2 × 3
pset6 × 3
caesar × 3
pset4 × 2
check50 × 2
vigenere × 2
server × 2
cs50-ide × 2
helpers × 2
array × 2
readability × 2
for-loop × 2
variables × 2