So i have this simple code that i've found here. I want to make it work in a loop. I've tried couple of times with diffrent methods but output is bad. Working in Ubuntu Visual Studio
EDIT I've added if(y>=2015 && y<=3000) and it is working properly?
EDIT 2 I've modified my code and followed @Sergey advice... It is still not working properly... I've tried to add "Check return value of scanf" but it is also not working.
        if ((scanf("%u", &d) == 1) && (scanf("%u", &m) == 1) && (scanf("%u", &y) == 1))
            while (fdateCheck());
        else
    //...EOF or conversion failure...
            while (fdateCheck());
or
while ((rc = scanf("%u.%u.%u", &d, &m, &y)) != EOF)
{
    if (rc != 3)
        //...oops data problems...
    else
        //...all OK...
}
Need advice about checking return of scanfs
int fdateCheck();
unsigned int d,m,y;
unsigned int daysinmonth[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int rc;
int legit = 0;
int main()
    {
        printf("Enter the date\n");
        scanf("%u.%u.%u",&d,&m,&y);
        while (fdateCheck());
    }
int fdateCheck()
    {   
        if (y % 400 == 0 || (y % 100 != 0 && y % 4 == 0))
            {
                daysinmonth[1]=29;
            }
            else if (y >= 2015 && y <= 3000)
                {
                    if (m < 13)
                        {
                            if (d <= daysinmonth[m-1])
                            legit = 1;
                        }
                    if (legit == 1)
                        {
                            system("clear");  
                            printf("It is a legitimate date!\n");
                            return 0;
                        }
                }
            else
                system("clear");     
                int ch = fgetc(stdin);
                if (ch == '\n')
                    {
                        system("clear");
                        printf("It's not a legitimate date!\n");
                        printf("\nRetry: ");
                        return 1;
                    }
                fflush(stdin);
    }
 
    