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. Tricks(四十八)—— 注释一段代码

    为 if 的条件判断表达式,传一个永假的语句,来注释一段代码: # Python if False: ... ... ... # C/C++ if (false) { ... ... } 永远不要直接 ...

  2. 【codeforces 779B】Weird Rounding

    [题目链接]:http://codeforces.com/contest/779/problem/B [题意] 问你要删掉几个数字才能让原来的数字能够被10^k整除; [题解] /* 数字的长度不大; ...

  3. Java中利用Math.random()产生服从泊松分布的随机数

    众所周知.Java的Math.random()产生的是服从均匀分布的随机数,可是其它分布的应用也相当广泛,比如泊松分布和高斯分布(正态分布).而这些分布Java没有非常好的提供(高斯分布能够利用Ran ...

  4. 【27.34%】【codeforces 611D】New Year and Ancient Prophecy

    time limit per test2.5 seconds memory limit per test512 megabytes inputstandard input outputstandard ...

  5. android studio的模拟器waiting for target device to come online原因

    android studio的模拟器一直waiting for target device to come online,demo也运行不上去 如图所示: 你很可能运行的android 6.0 (AP ...

  6. 在navicat上设置定时计划执行存储过程

    原文 应用情景: 有一个存储过程,需要每天定时执行一次.所以在navicat上使用事件处理,当然还有其他的方法,这只是一种.作为参考 1.事件定义填写 2.事件计划设置 3.保存 点击上方保存即可 常 ...

  7. Android菜鸟的成长笔记(18)——绑定本地Service并与之通信

    在上一篇中介绍了Service与Activity的区别及Service两种启动方式中的第一种启动方式startService(). 我们会发现用startService().stopService() ...

  8. 更改linux的最大文件描述符限制

    To ensure good server performance, the total number of client connections, database files, and log f ...

  9. Docker简单的使用命令

    Hello World 使用[docker run]命令在docker container中执行应用程序 <pre name="code" class="plain ...

  10. WPF 同一窗口内的多线程/多进程 UI(使用 SetParent 嵌入另一个窗口)

    原文 WPF 同一窗口内的多线程/多进程 UI(使用 SetParent 嵌入另一个窗口) WPF 的 UI 逻辑只在同一个线程中,这是学习 WPF 开发中大家几乎都会学习到的经验.如果希望做不同线程 ...