I've been having trouble creating a sorting program in C. I can get input from a text file, output that information into an Array and sort it numerically, though I've been unable to take into account characters from a text file.
What I'm looking to do is check the text file for characters, if a character is found, to send this to a seperate array, I've been messing around with the isalpha() function, when I run the below source code, the program seems to think every character and integer is an integer.
Code:
int Seperate_Alph_Int()
{
FILE *fp;
fp = fopen("c:\\test.txt", "r");
while (fscanf(fp, "") != EOF)
{
if(isalpha(fscanf(fp, "")) != 0) {
printf("Character");
return;
}
if(isalpha(fscanf(fp, "")) == 0) {
printf("Integer");
return;
}
}
}
Is there a way to get this to work? If not is there a better way of doing this?
Thanks.