There is a way, but like Salem said, it's definitely not portable. This works on my Linux box though:
Code:
itsme@itsme:~/C$ cat filethenstdin.c
#include <stdio.h>
int main(void)
{
char buf[BUFSIZ];
puts("Reading from stdin...");
while(fgets(buf, sizeof(buf), stdin))
fputs(buf, stdout);
freopen("/dev/tty", "rw", stdin);
puts("Reading from stdin again...");
while(fgets(buf, sizeof(buf), stdin))
fputs(buf, stdout);
return 0;
}
Code:
itsme@itsme:~/C$ cat search.txt
a
b
c
d
e
f
g
itsme@itsme:~/C$ ./filethenstdin < search.txt
Reading from stdin...
a
b
c
d
e
f
g
Reading from stdin again...
this is a test
this is a test
yay
yay
^d
itsme@itsme:~/C$
It works because /dev/tty always points to the user's terminal.