1

I'm having trouble verifying the argv[1] keyword along the guidelines of the assignment.

I've tried to implement an if ... else statement the checks if argc is 2 and argv[1] is alpha, if so, run the cipher, otherwise return 1. The problem was twofold:

  1. When I had the if ... else there, the cipher wouldn't work with check50, even though it would without the cipher. It gave the error: "expected prompt for input, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 7 (or 6 depending on the input in check50)...""
  2. isalpha doesn't work with strings, and the implementation of a for loop made the rest of the verification not work. The errors in check50 with this implemented are, for the cipher checks, it automatically exiting with 0, and for the lack of argv[1], it's "expected output, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 208...""

So, am I on the right track? Is there a function like isalpha that works with strings? What exactly am I doing wrong?

1
  • Welcome to SE. You don't need to hide an explanation of code, or pseudocode. It's never a bad idea to include error messages, though - helps us understand exactly what you're seeing.
    – Air
    Commented Aug 19, 2014 at 17:20

1 Answer 1

1

A string is just an array of chars. You can access each char in the string and then run isalpha on each char to make sure it is true (use a loop for this). You can use strlen to figure out the length of the string so you know how many iterations the loop needs to run through to check all of the characters, or you can just keep running the loop until you reach the string terminator \0 character.

If any single char !isAlpha, then you need to yell at the user. If all are alpha, proceed to your encryption function.

0

You must log in to answer this question.

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