c fopen

#include <iostream>
#include <plug/plug.h>
using namespace std;
int main()
{
    int pid = GetCurrentProcessId();
    auto path = Plug::GetCurrentPath();//返回std::wstring
    path += L"test.txt";
    auto file = _wfopen(path.c_str(), L"wb");//写或者新建一个二进制文件
    char buf[10] = {0};
    itoa(pid, buf, 10);
    fwrite(buf, 6, 1, file);//arg2:单个字节数,arg3:写入的个数,arg4:目标文件指针
    fclose(file);
    getchar();
    return 0;
}

感觉没有c++fstream方便

posted @ 2014-05-27 22:49  zzyoucan  阅读(188)  评论(0编辑  收藏  举报