I am trying to modify this function to read input in a noisy environment, meaning the characters received in the input may have extra characters.
A protocol that I am trying to implement is to send each digit twice in a row so that unless the receiver gets two of the same digit characters in a row, any other characters are ignored. It is assumed that there will be at least one integer per line.

For example, if the input is:
sw88zzx9cek44m, ,6ffe6qoi77#l85qaz22aaa
The output would be:

Here is the code I have so far:

#include <stdio.h> #include 
/* Function reads the next integer from a noisy input */
int get_noisy_int() 
{	int n = 0;
int got_dig = FALSE; 
signed char ch;

ch = getchar();
while (IS_WHITE_SPACE(ch)) 
ch = getchar();
while (IS_DIGIT(ch)) 
n = n * 10 + dig_to_int(ch); 
got_dig = TRUE;
ch = getchar();
if(ch == EOF) return EOF;
 if(!got_dig) return ERROR; 
return n;

Can anyone please give me some suggestions?

Separate reading digits and constructing a number. Something like

int get_noisy_digit()
    int ch1, ch2;
    while((ch1 = getchar())!= EOF) {
        if((ch2 = getchar()) == ch1)
            return ch1;
    return EOF;

That said, I doubt the protocol is any good.