Why is it possible to write() to STDIN?

前端 未结 3 1010
后悔当初
后悔当初 2020-12-30 14:13

I have the following code:

int main()
{
    char str[] = \"Hello\\n\";
    write(0, str, 6);   // write() to STDIN
    return 0;
}

When I c

3条回答
  •  清酒与你
    2020-12-30 15:05

    Are you confusing write with fwrite? The first parameter in write is a "file descripter", but it's not stdin. Try doing an fwrite to stdin -- it doesn't happen.

提交回复
热议问题