Ok I'm consistently encountering a peculiar issue that I can't get my head around. this loop should return an error if there is a character other than a digit. When I give a character other than a digit, such as A, a or [, it gives me the error message, but it also does when I give a single digit such as say 6 which is what it shouldn't do. The error message doesn't, however, pop up when I give a number such as 03 or 30 that recognises it as 3 or 30 and lets that be used as the encryption key. So what is going wrong with my loop here?
string d = argv[1];
for (int c = 0, l = strlen(d - 1); c <= l; c++)
{
if ((isdigit(d[1])) == 0 )
{
printf("This is an invalid entry\n");
return 1;
}
}