What is the relationship between a file pointer and a file descriptor

Updated on technology 2024-02-24
6 answers
  1. Anonymous users2024-02-06

    In C, a file pointer is a pointer to a file type, which points to the structure of a file type that contains the various properties of the file.

    A file pointer is used to keep track of the location of the current file. For example, if you enter a byte into a file, the file pointer will automatically move forward by one byte. The benefits of using file pointers, I haven't thought about it after learning it for so long.

    Yes, it is possible to access files randomly and abstract the io operation as a file operation.

  2. Anonymous users2024-02-05

    Otherwise you access the file through something.

    The file pointer is actually the one that is returned after opening the file"handle"You can use this pointer to read and write to the file, or locate the location of the file.

    The basic operations of the file are performed through it.

  3. Anonymous users2024-02-04

    In the file operating system, the number of files opened at the same time is limited, so in the operating system for the operation of the file is specially set up an area, in this area for each file operation to open an operation data area, in which each area corresponds to a file operation, record the file location, the current file pointer position, etc., if the file operation needs to obtain a valid data area allocated by the system, the number of this data area is the file handle, in C is the file * type.

    In the operation data area, there is a file pointer, which stores the current readable and written file location, which is a byte count value, after opening the current file, this pointer points to the first character of the file, and the value is 0, then if the immediate reading and writing of the file starts from the first byte of the file, assuming that the content of 1 byte is written or read, the file pointer will automatically change to 1 after the operation is completed, pointing to the next operable position. The file pointer can be moved back sequentially (increasing value) or forward (decreasing value), with the help of special functions, of course.

    Assuming that you want to get the file size, you can use a file pointer operation function (such as feek) to make the file pointer go to the end of the file after opening the file (the file pointer content is 0), and the file pointer value is the actual number of bytes of the file.

  4. Anonymous users2024-02-03

    The file pointer does not need to be assigned an initial value, but can only be null; Valid values for file pointers can only be generated using the fopen function, and once generated, it points to the beginning of the file being opened. If you need to move the file pointer to the beginning of the file in the middle of the process, you can use the rewind(fp) function in C to move the file pointer fp to the beginning. You can also close the file and open it again.

  5. Anonymous users2024-02-02

    File descriptor: Opening a file on Linux will give you a file descriptor, which is a very small positive integer. Each process keeps a table of file descriptors in the PCB (Process Control Block), which is the index of the table, and each entry has a pointer to the open file.

    File pointer: A file pointer is used as a handle to the IO in C. The file pointer points to a data structure called a file structure in the user area of the process.

    The file structure consists of a buffer and a file descriptor. A file descriptor is an index of a table of file descriptors, so in a sense a file pointer is a handle to a handle (on Windows, a file descriptor is called a file handle).

  6. Anonymous users2024-02-01

    The general form of a pointer to a defined documentation file is:

    file *pointer variable identifier;

    The file should be uppercase, and it is actually a structure defined by the system, which contains information such as the file name, file status, and the current location of the file. You don't have to worry about the details of the file structure when writing the source program.

    When using the file, you need to allocate space in memory for it, which is used to store the basic information of the file, and the structure type is defined by the system, and the C language stipulates that the type is the file type, which is declared as follows:

    typedef struct

    short level;

    unsigned flags;

    char fd;

    unsigned char hold;

    short bsize;

    unsigned char *buffer;

    unsigned ar *curp;

    unsigned istemp;

    short token;

    file;For example:

    file *fp;

    Indicates that fp is a pointer variable that points to the file structure, and you can use fp to find the structure variable that stores the information of a file, and then find the file according to the information provided by the structure variable, and perform operations on the file. It is also customary to refer to FP in general terms as a pointer to a file.

Related questions
3 answers2024-02-24

It doesn't matter, it's best not to delete this file in the future, take a look at the following content. >>>More

8 answers2024-02-24

First, you'll want to determine if the user you're currently using the operating system has superuser privileges. If not, you have to log in to Win7 as "adminisrtator", then in the Control Panel - Administrative Tools - Computer Management - Local Users and Groups - Users - Right-click on the user you started without permissions, in the pop-up menu, click Properties, in the pop-up menu in the selection tab: "Affiliation" - Add - Advanced - Find Now - (Select "administrators" in the search results, and then all the way.) OK. >>>More

6 answers2024-02-24

It's the same thing.

IE caching. In order to improve the speed of visiting web pages, the Internet Explorer browser will use a cumulative acceleration method to store the content of the web pages you have visited (including ** and cookie files, etc.) on your computer. This storage space is called IE cache. >>>More

10 answers2024-02-24

Don't go into that many details.

In the final analysis, it is to be familiar with the bidding documents, and the preparation of bidding documents according to the requirements of the bidding documents is the most fundamental. Everything else is puffy clouds. >>>More

10 answers2024-02-24

Give me an email... I send you the word2011 and cracker I used.。。。