In short, you can't. Redirection is identical to you typing on the keyboard. There is no difference as far as C is concerned. So, you either have it check for EOF, and the user must then enter EOF themselves, or you have it read one line at a time.
The closest to getting what you want is going to be setting up some form of prompt:
Code:
printf("If reading from the keyboard, enter something now: ");
if( (c = getchar() ) == something )
{
...reading from keyboard, use first loop...
}
else
{
...reading from file, use second...
}
Or, you could so something fun like:
Code:
while( c == something ? (x=getchar()) != '\n' : (x=getchar()) != EOF )
{
...do whatever...
}
But again, there's always the slight chance that the first byte of the piped file matches something, so it throws off your efforts. So in closing, you can try, but there's no guarintee. But really, is it all that much trouble to prompt for CTRL+D from your users?
Quzah.