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[(...
user avatar
  • 64.2k
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("...
user avatar
  • 312
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.
user avatar
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 ...
user avatar
  • 450
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 ...
user avatar
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 ...
user avatar
  • 64.2k
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 ...
user avatar
  • 20.7k
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 ...
user avatar
  • 20.7k

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