working through some C problems and am hitting a wall with this. I can think of another way or two around this, but I'd like to understand better why my check is failing.
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
int main(int argc, char *argv[256]){
//Require one alpha only argument if else exit 1
if(argc < 2){
printf("Usage: ./vigenere arg1 [arg2] [arg3]...\n");
return 1;
}
for (int i=1;i<argc;i++){
if(isalpha(argv[i]) == 1){
return 1;
}
printf("%d\n",i);
}
//Prompt the user for some plaintext
//Rotate plaintext by argument
//Print Rotated Text
// exit 0
}
The script is working as expected until the isalpha()
line. I'd assume argv's that have non-alpha characters in them would !=0 ergo skipping my return(1). However it seems to fail regardless of what is inserted as an argument.
Any thoughts?