This is a common newbie mistake. The isdigit() function, like all of it's issomething functions take a single char as input. But, argv[1] is a string, so feeding a string to this function will cause it to choke and cough up a seg fault.
Further, in this case, k is an int. The isdigit() function simply won't operate on an int.
There's also the problem that if there's a non-digit in the string argv[1], then it will not convert the string to an int. (I don't remember if it throws an error or just puts 0 in the int. You can look it up.)
The right way to do this is to apply isdigit() to each char in the string argv[1] string, say, by using a for loop. Only after confirming that each char really is a digit should you then use atoi to store the actual number in an int.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)