3
votes
Accepted
expected expression pset5 dictionary.c if-else
The problem is bad structuring of the chain of ifs and else ifs. Look at the following:
if(...)
{
...
}
else if (isupper((char)*(word + i))) {
else if (cursor -> children[(...
2
votes
During PSET 2: Substitution, I got an expected expression error for get_string. Please help
Your get_string() has no arguments, while in the lectures we've been taught to always insert a prompt (in the form of a string) in between the parentheses.
Try combining these two lines:
printf("...
1
vote
Accepted
How to solve "error: expected expression" while doing Caesar.c
This doc shows the correct syntax for the typecast operator in C.
Syntax
( type-name ) expression
Typecasting is demonstrated in the lecture at around 1:03:00.
1
vote
Accepted
Cash.c:11:24: error: expected expression
#include <cs50.h>
#include <math.h>
int main(void) {
int n = 0;
do {
n = (get_float("Change owed: ") * 100);
} while (n < 0);
int q = ((n / 25) % 10); //<- need ...
1
vote
Accepted
Pset 2 Caesar "Expected Expression" - If statement
An expression is something that returns a value, like strlen(argv[1]) or i++. This int n = strlen(argv[1]) is a declaration or assigment operator.
In a for statement, only the first argument allows ...
1
vote
Accepted
"Expected Expression" Error on Move Function
These are all syntax errors. In the case of the first two, it's an incorrect initialization, more or less. I'll explain. in order to use the {...} technique, you have to do this at the same time as ...
1
vote
Accepted
Pset3 Find - error in "helper" file - 'expected expression'
If you adjusted the indentation to match the curly braces, you'd realise that you put the else after the for loop, not one level higher after the if.
You don't need that outer if, as your for loop ...
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
expected-expression × 11error × 3
pset2 × 2
pset1 × 2
pset5 × 1
c × 1
caesar × 1
greedy × 1
cs50-ide × 1
game-of-fifteen × 1
check × 1
cash × 1
move × 1
pset × 1
pset2-caesar × 1
compilation-error × 1
compile-error × 1
substitution × 1
functions × 1
cipher-pset2 × 1
selectionsort × 1
getstring × 1
pset3-fifteen × 1
else × 1
vscode × 1