Hola; una mirada al estándar [URL="http://port70.net/~nsz/c/c11/n1570.html#7.21.6.4"]C11[/URL] (clic para ver) nos dice que
Cita: 3 The scanf function returns the value of the macro EOF if an input failure occurs before the first conversion (if any) has completed. Otherwise, the scanf function returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of an early matching failure.
Un ejemplo para estos casos puede ser:
Código C:
Ver original#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int res
= scanf("%d", &n
);
if(res == 0)
printf("end-of-file reached.\n"); // Ctrl+Z en Windows
return 0;
}