Conversion functions between file and INT file descriptors

Source: Internet
Author: User

Convert file *'s file descriptor to int type FD function: int fileno (File * tream)The file descriptor function for converting int FD file descriptors to file * is file * fdopen (int fd, const char * mode ). After mutual conversion, the two point to the same stream. If one of them is disabled, the other is also disabled. If you try to disable

Then an error is returned. For example, if the file * type is used, if fileno is called to obtain an int type, fclose () is called first to close the table. If close () is called, an error is returned.

In UNIX system calls, stdin is used for standard input description and stdout is used for standard output. stderr is used for standard errors. However, in some call functions, stdin_fileno is referenced to indicate standard input. Similarly, stdout_fileno is used for standard access and stderr_fileno is used for standard errors.
Their differences:
Stdin is of the file * type and belongs to the standard I/O, in <stdio. h>.
Stdin_fileno is a file descriptor and is a non-negative integer. It is generally defined as 0, 1, and 2. It belongs to the I/O without buffer and directly calls the system call in <unistd. h>.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.