How to read from text file only numbers in C. Except spaces, symbols, enters and letters.
That’s how i am reading text:
unsigned char symb, symb1;
FileIn = fopen("InCode.txt","rt");
while (!feof(FileIn))
{
symb=getc(FileIn);
symb1=symb;
printf("%c",symb1);
}
This is how it should work:
/* Data in the file: */
12hj2 3h23j1
/* Output: */
1223231
Try this :
If
symbis between0to9you print it . And discard all other characters as you mentionedspace,newline,alphabats(lower & upper) , any other symbols .