I wrote to standard input and it appeared on screen (0 standard input, 1 standard output, 2 standard error
const int SIZE=12;
int main()
{
int fd = open("input.txt", O_RDWR);
char buffer[SIZE] = "Hello world";
write(fd, buffer, SIZE - 1);
lseek(fd, 0, SEEK_SET);
char mem[SIZE];
read(fd, mem, SIZE - 1);
mem[SIZE] = '\0';
write(0, mem, SIZE - 1);
printf("\n");
write(1, mem, SIZE - 1);
printf("\n");
write(2, mem, SIZE - 1);
printf("\n");
return 0;
}
Output:
Hello world
Hello world
Hello world
How this works? Doesn't standard input connected to keyboard?
Thanks.