This works on my Linux box, your mileage may (and probably will) vary. You should consider this super-platform-dependant. If you would like to know more about the guts of stdin on your machine, fire up your favorite debugger and pick it apart.
Code:
#include <stdio.h>
int main( void )
{
char x[10];
void *ptr;
fgets( x, 10, stdin );
ptr = stdin->_IO_buf_base;
memcpy( ptr, "HAHAHA", 6 );
stdin->_IO_read_ptr = ptr;
fgets( x, 7, stdin );
printf( "%s\n", x );
return (0);
}
Regardless of what you type into the buffer on the first call to fgets(), the printf() will display: HAHAHA
Hope this helps.