Can anyone give me a hand with such problem? I wrote a function to get input
only integers. The function accepts only digits, then transfers string into
integer number. But in the case if the user wants to change some digits,
using Backspace key it is not working. I would be appreciating for any help.



unsigned long get_prod_code(const unsigned long min, const unsigned long
max)
{
char string[MAX_LENGTH];

unsigned long a = 0;
int i =0,
cnum = 0;

do
{
while ((cnum = (char)getch()) != NEW_LINE )
{
if ( !isdigit(cnum) && cnum != 8)
continue;

else
putchar(cnum);

string[i++] = (char)cnum;
}

string[i] = NULL;
/* Test whether the entered number within
* min and max frame */
a = atol(string);

if (a < min || a > max)
{
INVALID_INPUT;
i = 0; /* Reset string */
string[i] = NULL;
PRINT_PROMPT;
}
else
break;

} while(1);

return(a);
}