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

Linux下的wfopen(手工打造)的更多相关文章

  1. 用Zebra打造Linux下小型路由器

    用Zebra打造Linux下小型路由器 现在的Internet网络相当庞大,不可能在不同的网络之间建立直接的连接,所以这时就必须用路由器为不同网络之间的通信提供路径选择.Linux下搭建路由器价格非常 ...

  2. 打造linux下的source insight——vim插件安装使用总结

    source insight是windows下的优秀编辑器,适合阅读管理代码,主要有以下功能: 查找函数,变量或者宏的定义. 查找函数,变量或者宏的引用位置. 查找函数被调用的位置 查找某个符号在工程 ...

  3. linux下C++开发工具

    就C++开发工具而言,与Windows下微软(VC, VS2005等)一统天下相比,Linux/Unix下C++开发,可谓五花八门,各式各样.Emacs, vi, eclipse, anjuta,kd ...

  4. 纯手工打造简单分布式爬虫(Python)

    前言 这次分享的文章是我<Python爬虫开发与项目实战>基础篇 第七章的内容,关于如何手工打造简单分布式爬虫 (如果大家对这本书感兴趣的话,可以看一下 试读样章),下面是文章的具体内容. ...

  5. linux下mono播放PCM音频

         测试环境: Ubuntu 14 MonoDevelop CodeBlocks 1.建立一个共享库(shared library) 这里用到了linux下的音频播放库,alsa-lib. al ...

  6. 记录在linux下的wine生活

    记录在linux下的windows生活 本篇内容涉及QQ.微信.Office的安装配置 QQ: 到deepin下载轻聊版. 如果安装了crossover,那么将其中opt/cxoffice/suppo ...

  7. Linux下的DOS攻击

    Linux下的DOS攻击 DOS是Denial of service的简称,即拒绝服务,造成Dos攻击行为被称为Dos攻击,其目的是使计算机或网络无法提供正常的服务.最常见的Dos攻击有计算机带宽攻击 ...

  8. Linux学习心得之 Linux下命令行Android开发环境的搭建

    作者:枫雪庭 出处:http://www.cnblogs.com/FengXueTing-px/ 欢迎转载 Linux学习心得之 Linux下命令行Android开发环境的搭建 1. 前言2. Jav ...

  9. Linux下运行Jmeter测试所遇问题汇总

    一.安装及启动Jmeter  本文原创,专为光荣之路公众号所有,欢迎转发,但转发请务必写出处!  0.下载及安装 下载地址及Linux命令 wget http://mirrors.cnnic.cn/a ...

随机推荐

  1. NOIP模拟 Math - 数学

    题目大意: 给定a,n(\(a \le 1e9, n\le30\)),求有多少\(b(1 \le b \le 2^n)\)满足:\(a^b \equiv b^a(mod 2^n)\). 题目分析: 数 ...

  2. 手机预览微信小程序

    1. 获取微信小程序的 AppID 登录 https://mp.weixin.qq.com ,就可以在网站的“设置”-“开发者设置”中,查看到微信小程序的 AppID 了,注意不可直接使用服务号或订阅 ...

  3. Linux下用GCC

    Linux下用GCC 前言 离职前对做过的支付系统进行了一番#总结,继续完善我的C服务器. 本想着接下来大概实现一下 CGI 协议,但是实现过程中被一个问题卡住了: C进程与php进程的交互数据类型问 ...

  4. jdk 8 lambda表达式以及Predicate接口

    了解lambda之前先了解下什么是函数式接口,函数式接口即接口里必须有一个抽象方法(抽象的方法只能有一个,可以有其他的用default修饰的方法) jdk8里新增了一个@FunctionalInter ...

  5. codeblocks如何设置,启动后自动打开上次未关闭的workspace

    设置--环境--普通设置--on application start-up -------default 关闭code::blocks时不要关那个workspace就可以.至于其它方法就不知道了.

  6. Java8初体验(二)Stream语法详解---符合人的思维模式,数据源--》stream-->干什么事(具体怎么做,就交给Stream)--》聚合

    Function.identity()是什么? // 将Stream转换成容器或Map Stream<String> stream = Stream.of("I", & ...

  7. WinForm - 无边框窗体自定义移动

    为了界面的好看,有时候需要将窗体FormBorderStyle属性设为None,这样就可以根据自己的喜欢来设计界面.但这样窗体无法进行移动的.而且默认的窗体(FormBorderStyle=Sizab ...

  8. Fast-tracking approach for building routing topologies in fast-moving networks

    In one embodiment, a local node in a communication network determines a set of its neighbor nodes, a ...

  9. ListView 泛利

    0ListView基本属性 1介绍 Listview节约内存的几种写法 2技巧一:解决ListView的ItemView中带有Button时,OnItemClick无效的问题  3技巧二Listvie ...

  10. win7 UAC bypass(微软已经给予了三组组件绕过UAC启动的特权)

    fireworm同学的翻译: 原文在http://www.pretentiousname.com/misc/win7_uac_whitelist2.html我只翻译了其中关于原理的一小部分,有兴趣的可 ...