This is about Problem Set 2, week 3, caesar.c. My code doesn't store the int I get from the user via GetInt() in argv. Consequently, argc stays at value 1 and the one command line argument given by the user is refused, which is not what I want. Why isn't the input stored?

    int main(int argc, string argv[])
        int old_value, new_value;
        char new_string;
        bool upper = 0;

        int i = GetInt();
        if (argc != 2)      
            printf("Enter an integer (and nothing else) please: ");
            return 1;
            int k = atoi(argv[1]);

            printf("Enter some plaintext to encrypt: ");

1 Answer 1


The command line argument doesn't get passed to main via GetInt(). It gets passed via the command line. You do something like

./caesar 13

And 13 is stored in argv[1]

Watch the walkthroughs and the shorts for command line arguments

  • Also, GetInt() isn't storing in argv, it's storing the integer exactly where you told it to, in the variable i.
    – Cliff B
    Commented Nov 5, 2015 at 5:08
  • Thanks a lot Irene. And Cliff.
    – swissfritz
    Commented Nov 6, 2015 at 6:40

You must log in to answer this question.

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