What do FILE struct members mean exactly in C?

前端 未结 2 1481
忘掉有多难
忘掉有多难 2020-12-20 03:15
typedef struct _iobuf{
    char*   _ptr;
    int     _cnt;
    char*   _base;
    int     _flag;
    int     _file;
    int     _charbuf;
    int     _bufsiz;
    ch         


        
2条回答
  •  旧时难觅i
    2020-12-20 03:41

    Look at the source code for your system's run-time libraries that implement the FILE-based IO calls if you want to know what those fields mean.

    If you write code that depends on using those fields, it will be non-portable at best, utterly wrong at worst, and definitely easy to break. For example, on Solaris there are at least three different implementations of the FILE structure in just the normal libc runtime libraries, and one of those implementations (the 64-bit one) is opaque and you can't access any of the fields. Simply changing compiler flags changes which FILE structure your code uses.

    And that's just one one version of a single OS.

提交回复
热议问题