0

I am working on pset2 vigenere problem. When I run ./vigenere I keep getting this message. I looked it up online and it seems like I did not check argv before use it (?). I do not know what does it mean since I did same thing in caesar problem and it works fine. How do I check argv then? My code is below: enter image description here

enter image description here

0

Before you use argv[1] you need to be sure it actually exists. You should check if argc is 2 first. If it's not, then you can exit the program gracefully with an error message, as it says in the spec:

If your program is executed without any command-line arguments, with more than one command-line argument, or with one command-line argument that contains any non-alphabetical character, your program should print an error (of your choice) and exit immediately, with main returning 1 (thereby signifying an error).

2

You must log in to answer this question.

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