I have a binary of a program that waits for an input using scanf. I need to write a C code that will be able to simulate keyboard input. i.e. close the stdin pointer for that binary and instead repoint it to a file.
I used this code

```
int main()
{
        FILE *fin;
        int result;
        char string[80];
        close(0);

        fin = fopen("text", "r");

        if(NULL == fin)
        {
                printf("Unable to open file.");
                return 0;
        }
        dup(fin);
        return 0;
}

```

But i found that each program has its own stdin pointer. Is there a way for me to simulate 
keyboard input for one binary from another C program ?