Of Linux on wfopen (open wide-character version of the file name and mode) to achieve

Not directly available on Linux wfopen function is used to open a wide-character file name, then we can convert a wide character char type, and then call the fopen function.

#include <stdio.h>
#include <wchar.h>
#include <stdlib.h> #define MAX_PATH 1024 FILE* wfopen(const wchar_t* filename, const wchar_t* mode)
{
char fn[MAX_PATH];
char m[MAX_PATH];
wcstombs(fn, filename, MAX_PATH);
wcstombs(m, mode, MAX_PATH);
return fopen(fn, m);
} #define SIZE 4 struct person
{
char name[];
int year;
int month;
int day;
}personArray[SIZE]; int main()
{
wchar_t *filename = L"/Perforce/sandbox/1.txt";
wchar_t *mode = L"r"; FILE* pFile = wfopen(filename, mode);
if(pFile)
printf("File open successeed!\n");
else
printf("File open failed!\n"); /* int i;
for(i = 0; i < SIZE; i++)
{
if(fread(&personArray[0], sizeof(struct person), i, pFile) != 1)
{
printf("File read failed at fread!\n");
}
} fclose(pFile); for( i = 0; i < SIZE; i++)
{
printf("%s, %d, %d, %d", personArray[i].name, personArray[i].year, personArray[i].month,
personArray[i].day);
printf(" ");
} printf("\n");*/ /* use the second test case to test*/
int c;
while( (c = fgetc(pFile)) != EOF)
{
printf("%c", c);
}
fclose(pFile); return ;
}

http://intercontineo.com/article/840436823/
http://man7.org/linux/man-pages/man3/wcstombs.3.html

最新文章

  1. 1.Two Sum(c++)(附6ms O(n) accepted 思路和代码)
  2. 使用Gson转换json数据为Java对象的一个例子
  3. 如何为Eclipse安装主题(Color Theme)
  4. C# ~ NUnit单元测试
  5. js控制全屏窗口
  6. NGITOSS
  7. hdu 5310 Souvenir(BestCoder 1st Anniversary ($))
  8. 杭电ACM2097--Sky数
  9. spring mvc 错误
  10. MySQL数据库MyISAM和InnoDB存储引擎的比较(转)
  11. JavaScript电话号码正则
  12. nginx+php-fpm json_encode 到client pages 截断
  13. vue 父子组件传参
  14. foreach_and_函数
  15. C++雾中风景1:友元类与面向对象
  16. 软件配置管理及SVN的使用
  17. Mybatis框架基础支持层——反射工具箱之泛型解析工具TypeParameterResolver(4)
  18. Android冷启动优化
  19. Java构造器练习题
  20. 常见HTTP状态码及URL编码表

热门文章

  1. MinGW安装和使用(不是mingw-w32)
  2. 【BZOJ 2534】Uva10829L-gap字符串
  3. this解析
  4. Linq知识小总结
  5. Android官方教程翻译(3)——创建一个简单的用户界面
  6. 1 WCF 一个基础理论 以及如何实现一个简单wcf服务
  7. 在vs中启动项目,同时给项目传递参数
  8. AdaBoost算法原理及OpenCV实例
  9. JS数组操作:去重,交集,并集,差集
  10. Python 实现 淘宝秒杀 聚划算 自己主动提醒 源代码