C语言中的输入输出 (Input & Output)

风行水上 @ 2010-06-09 09:49:43
标签:

    在C语言中,在涉及文件IO时,有两种不同的方式:Fiel Descriptor(文件描述符) 和 Steam(流)。
    两种方式者可以用来操作IO,只是 Fiel Descriptor 更底层(Low-Level),因此有些情况下就只能用 File Descriptor。

    Steam 是建立在 File Descriptor 之上的,所提供的IO操作更易用,更丰富。

    File Descriptor 用一个整数类型 int 来表示。Stream 则用 数据类型 FILE * 来表示。

    File Descriptor 与 Steam 之间的类型转换

    // Descriptor to Steam
    FILE * fdopen (int filedes, const char *opentype);
    
    // Steam to  Descriptor
    int fileno (FILE *stream);
    
    int fileno_unlocked (FILE *stream);
    
    标签:

      分享到:
      comments powered by Disqus

      16/18ms