Check that program was run with one command-line argument. Iterate over the provided argument to make sure all characters are digits. Convert that command-line argument from a string to an int.

code :

int main (int argc , string argv[] ) { if ( argc != 2) { printf("Usage: ./caesar key"); return 1; } else if ( isalpha(argv1)) { printf("Usage: ./caesar key"); return 1; } else{ int key = atoi( argv1); return 0; } }

and i keep on getting error of segmentation faultenter image description here

1 Answer 1


isalpha, isdigit, islower and so on require you to pass a single char, not a string. If those were regular functions, you would get a compiler error.

So check isdigit in a loop, one character at a time.

You must log in to answer this question.

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