I have written the program which creates pipe, write a number to pipe, read it from pipe and print it to stdout. But it seems to be that fscanf see empty pipe stream, although I made fflush.
Why fprintf does not print anything?
int main() {
int fd[2];
pipe(fd);
FILE* write_file = fdopen(fd[1], "w");
FILE* read_file = fdopen(fd[0], "r");
int x = 0;
fprintf(write_file, "%d", 100);
fflush(write_file);
fscanf(read_file, "%d", &x);
printf("%d\n", x);
}