Q:

Can "tee" command in linux print both the input and the output of a C program?

I have a simple C program where the it will ask to take an integer from the user, and then it will print that integer.
#include <stdio.h>
int main() {   
    int number;
    printf("Enter an integer: ");  
    scanf("%d", &number);
    printf("You entered: %d", number);  
    return 0;}

When I use this command:
gcc program.c -o test
./test | tee text.txt

The program running on terminal does not print the enter integer line but instead, waits for an input and when I provide that input, it prints it and also into the text.txt folder. I want to run the program as it is and store everything running on terminal into the text.txt folder including both the input and the output. Any possible way to do that?

A:

The tee command works with one input, but you want to capture two.  With some care, you could use two separate tee commands two copy both the input and the output to the same file, but you would be better off with a utility designed for your purpose, such as script.

