Home C&C++函数库 c++ 语法 程序源码 Linux C库

fwide

函数   <cwchar>

int fwide (FILE* stream, int mode);

流模式

确定流的模式,如果它还没有确定模式,可以根据mode的值设置。

当打开时,流没有区分模式(包括stdinstdoutstderr)。 但是对一个流执行的第一个i/o操作会自动设置它的模式:
如果它是一个面向字节的函数(在<cstdio>中定义),流就变成面向字节的;
如果它是一个面向宽字节的函数(在<cwchar>中定义),流就会变成面向宽字节的。


通过调用这个函数,可以在任何i/o操作之前显式地确定模式。 在已经有确定模式的流上调用这个函数不能改变它的模式 (只有在调用了freopen之后,才能改变它)。

该函数可以通过使用0作为mode来获取流的当前模式。

☲  参数


stream
指向标识流的FILE对象的指针。

mode
可以指定模式:

☉  返回值



函数在调用后根据流的模式返回一个值:

☣  示例



/* fwide example */
#include <stdio.h>
#include <wchar.h>

int main ()
{
  FILE * pFile;
  int ret;

  pFile = fopen ("myfile.txt","a");
  if (pFile) {
    fwide (pFile,1);
    ret = fwide (pFile,0);
    if (ret>0) puts ("The stream is wide-oriented");
    else if (ret<0) puts ("The stream is byte-oriented");
    else puts ("The stream is not oriented");
    fclose (pFile);
  }
  return 0;
}

输出:
The stream is wide-oriented

🍄  另请参阅



fopen 打开文件(function )
freopen 以不同的文件或模式重新打开流(function )

联系我们 免责声明 关于CandCplus 网站地图