I am receiving an error that states my first curly brace is bad. I have copied this code from lecture 1 and tried to run it because I keep seeing the same error. I believe that my code is identical to the lecture example. The error says that "(" is expected. Any help?

#include <cs50.h>
#include <stdio.h>

int main (void);
    int age = get_int("What's your age?\n");
    int days = *365;
    printf("You are at least %i days old.\n", days);

1 Answer 1


The problem is not the { per se, that's just where the compiler finds a problem. The problem is the ;. If program is defining a function prototype the ; would be necessary (and the function logic would come later in the program). Since main is the main loop of the program the correct declaration is

int main(void) {

FYI if you expand the Source Code option under the lecture on the class page, and choose Index, you can download any/all the sources from the lecture.

screen grab

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .