thanks for the answer. I tried to use a for loop, like this,

 for (int i = 0; i <= argc; i++)
           if (isalpha(*argv[1]))
               printf ("Usage: ./caesar key\n");
               return 0;

but it didn't help. I think the main problem was what to put in the square brackets here (*argv[1]). Any ideas? Thanks in advance!

1 Answer 1


Why is argc even involved in this? argc is the number of arguments (each is a string) used to execute the program. argv[0] is the program name. argv[1] is the first string that follows, and so on. You need to understand that argv is an array of strings, not a single string (i.e., an array of chars.) So, if a program is executed with 4 parameters, then argc would be 5 and argv would be an array of 5 strings.

You need to use a for loop to step through the string argv[1] to check each char. To do that, you need to realize that argv is a 2 dimensional array and you're checking all the chars in one row. Think in terms of argv[1][i]. The for loop needs to run from 0 to strlen(argv[1]).

Hopefully, this explains it in enough detail that you can figure out how to code it.

Happy programming.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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