[C] 把流与一个文件句柄相接 →→→→→进入此内容的聊天室

来自 , 2020-11-10, 写在 C, 查看 113 次.
URL http://www.code666.cn/view/01eee509
  1. #include <sys\stat.h>
  2. #include <stdio.h>
  3. #include <fcntl.h>
  4. #include <io.h>
  5.  
  6. int main ( void )
  7. {
  8.         int handle;
  9.         FILE *stream;
  10.  
  11.         /* open a file */
  12.         handle = open ( "DUMMY.FIL", O_CREAT,
  13.                         S_IREAD | S_IWRITE );
  14.  
  15.         /* now turn the handle into a stream */
  16.         stream = fdopen ( handle, "w" );
  17.  
  18.         if ( stream == NULL )
  19.                 printf ( "fdopen failed\n" );
  20.         else
  21.         {
  22.                 fprintf ( stream, "Hello world\n" );
  23.                 fclose ( stream );
  24.         }
  25.         return 0;
  26. }
  27.  

回复 " 把流与一个文件句柄相接"

这儿你可以回复上面这条便签

captcha