Hey to check that the user is entering just alpha I have it set as:

If (!isalpha(argv[1])) && (argc != 2)
Yell at user

The argc check works fine on its own. The isalpha check returns a segmentation fault. Then I am not able to use the && to combine them, I get an error. What am I doing wrong?

1 Answer 1


isalpha() takes a single character as a parameter. You are trying to shove an entire string down its throat, so it chokes on it and gives you back a seg fault.

If you want to check the string, you need to loop through argv[1] and check each char individually.

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

  • Thanks, didn't realize about isalpha for characters only.
    – jnhustin
    Apr 30, 2016 at 1:12

You must log in to answer this question.

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