0

So i just started caesar, and I think the checking for argc being 2 is pretty easy so i wrote:

int main(int argc, string argv[])[

if(argc < 2 || argc > 2){
    return 1;
}
else if( argc == 2){
    return 0;
}

}

but no this error pop ups:

caesar.c:8:5: error: expected expression if(argc < 2 || argc > 2){ ^ caesar.c:15:2: error: expected function body after function declarator } ^

i don't know what either means and i can't move on.....

1 Answer 1

0

Two points:

  1. You start your main function with a square bracket ("[") instead of curly brace ("{").
  2. Your condition "if (argc < 2 || argc > 2)" can be more simply stated as "if (argc != 2)"
2
  • Well the errors are gone now, but even if i type ./caesar or ./caesar foo bar, then nothing happens... Commented Aug 6, 2015 at 10:51
  • Does main still return 0 if argc == 2? Please edit your code above to reflect your changes. You only need to check if there are not two arguments at the command line. Otherwise, your code should then continue executing without returning any value until afterwards.
    – L.B.
    Commented Aug 6, 2015 at 15:08

You must log in to answer this question.

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