I wrote the following little test program to test out the isalpha function:
Code:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
main(int argc, char * argv[] )
{
FILE * fp = fopen( argv[1], "r" );
printf( "%d\n%d\n%d\n%d\n", isalpha(fgetc(fp)), isalpha(fgetc(fp)), isalpha(fgetc(fp)), isalpha(fgetc(fp)));
}
And ran it using this as my input text file:
And got the following output:
According to what I've read, the isalpha function should produce non-zero values when given the letters 'a' and 'b', and it should produce zero when given '&' and '-'. This is the exact opposite of what the above code shows. Can someone tell me what's going on? Could there be a bug in this function? I'm using gcc to compile.