0

before you block my answer for duplicates, I've spent over a day on this small bug. I've searched reddit, youtube and the stack exchange forums and still can't get it to work. I'm hopeless at this point and really need someone to specifically check my code. That being said.

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

int main(void);
int height;


{



do {

     printf("Height:");
     height = get_int();
   } 
   while ( height < 0 || height > 23 );

}

And I get this error from the terminal:

~/workspace/pset1/ $ make mario
clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall         -Werror -Wextra -Wno-sign-compare -Wshadow    mario.c  -lcrypt -lcs50 -lm -o mario
mario.c:8:1: error: expected identifier or '('
{
^
1 error generated.
make: *** [mario] Error 1

Any help would be appreciated!

0

The declaration of your main function needs to be as so:

int main(void)
{
    ...code...
}

Notice the positions of curly braces relative to the declaration and the lack of semi-colons.

| improve this answer | |
  • Thanks! is there ever a circumstance where there's code before the curly braces? – Tim Feb 9 '17 at 10:24
  • You can, and more than likely will at some point, have code before the int main(void) declaration but you would never have it in between the int main(void) and the {. – Steve Bunting Feb 9 '17 at 10:28

You must log in to answer this question.

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