In this piece of code
while(scanf("Dia %d %d : %d : %d Dia %d %d : %d : %d",&day_start,&h1,&m1,&s1,&day_end,&h2,&m2,&s2)==8)
after the first execution the last enter-key pressed is taken as the first character of the second scanf
which it must be D
to continue, and this can't be reached.
while in this piece of code
while(scanf("Dia %d %d : %d : %d Dia %d %d : %d : %d",&day_start,&h1,&m1,&s1,&day_end,&h2,&m2,&s2)==8)
{
getchar();
......;
}
the last enter-key goes to getchar()
not to scanf