My code prints out only the first letter. What am I missing?enter image description here

2 Answers 2


First, it is better to use if() statement than while() statement for checking the number of command line arguments.

Second, you are not printing the characters which are not alphabets. So do include a statement which prints those non-alphabetic characters.

Third, you are unnecessarily declaring int m and c, you can directly initialize the ciphered letter to char or you can directly print it without using any variables.

Also when i ran your code on my machine it was printing all alphabetic characters as it is supposed to.

One more tip, if you are checking a character using islower() or isupper(), you need not check it first using isalpha() as you did above, because isalpha() is essentially equivalent to ( islower() || isupper() ). Hope this helps.


Have a look at your for loop, what is the last thing your for loop does after the first run through? That should help you figure out why it only prints one character.

You must log in to answer this question.

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