前段时间你帮我读了一行。现在,我只想从输入中读取数字 - 没有字母,只有 5 位数字。我怎样才能做到这一点?
我的解决方案无法正常工作:
int i = 0; 
while(!go)
    {
        printf("Give 5 digits: \n\n");
        while( ( c = getchar()) != EOF  &&  c != '\n' &&  i < 5 )
        {
            int digit = c - '0';
            if(digit >= 0 && digit <= 9)
            {
                input[i++] = digit;
                if(i == 5)
                {
                    break;
                    go = true;
                }
            }
        }
    }