0

i am starting out with caesar cipher. encloed is whole screen shot which baffles me. i am in caesar directory, with caesar1.c file. there is no code beyond line 26.

pl see the few lines that i have started with then go to terminal window display.

questions 1. first attempt to compile caesar1 gives error message on line 10, column-1 which i cant understand why 2 if I give two arguments at command line, the program actually works- prints out my second argument (contained in argv1)when i have not asked to print it.why? 3. a line from my previous program appears.. are program lines getting mixed in cyberspace?? would appreciate your help screen shot captured

2
  • cant see my uploaded screen shot here!
    – sudhir
    Commented Jan 28, 2017 at 21:18
  • There was a line break in the image description, removed it, image is working :)
    – Blauelf
    Commented Jan 28, 2017 at 21:37

1 Answer 1

0

Remove the semicolon in line 8.

By placing a semicolon after the int main(int argc, char** argv), you make it a function declaration, which is a valid thing, but never followed by curly braces, that's why the parser complains. A function declaration is meant to inform the compiler what the function signature looks like (variable names are optional in the declaration), so you can call a function defined below the current code.

The actual function does not have a semicolon, but a code block in curly braces {}.

Another problem is that you declare two variables of the same name k.

Also, first test argc, only then access argv[1]. If you passed no arguments, argv[1] could be anything, especially not pointing to a string you could pass to atoi.

You must log in to answer this question.

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