I'm trying to write a C program that goes through a string of characters, and prints out "NON-LETTER" if the given argument through the command line.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char **argv)
{
int i = 0;
for (i = 1; i < argc; i++){
if (!isalpha(argv[i])){
printf("NON-LETTER\n");
}
}
return 0;
}
But I'm getting a segmentation fault.
Is this because of the comparison I'm making with isalpha()
? It looks like argv[i]
is a string?