R__
R__

Reputation: 1531

What's the int macro for stdin?

stdin is of type FILE *,

is there a fd macro for it?

Or do I need to convert it myself?

Upvotes: 21

Views: 17914

Answers (4)

Akshay Mandalik
Akshay Mandalik

Reputation: 11

#include<unistd.h>
#include<stdlib.h>
int main(){
    
    char ch;
    read(STDIN_FILENO,&ch,1);
    write(STDOUT_FILENO,&ch,1);

    exit(EXIT_SUCCESS);
}

Upvotes: 1

user7116
user7116

Reputation: 64148

The following are the integer file descriptors for the standard streams:

  • 0: stdin
  • 1: stdout
  • 2: stderr

Upvotes: 2

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84239

STDIN_FILENO from unistd.h

Upvotes: 38

robert
robert

Reputation: 34458

fileno(stdin)

Upvotes: 7

Related Questions