unicode是否支持fstream [英] whether fstream is supported in unicode

查看:91
本文介绍了unicode是否支持fstream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void CSoftwareLinkList::FileToList(){

    if(!PathFileExists(ListFileName))
    {
        wprintf(L"\n Inside SoftwareLinkList.cpp :-> In FileToList() : %s File Name Not Exist", ListFileName);

    }else{

        wfstream infile(ListFileName , ios :: in);

        if (!infile){

            wprintf(L"\n Inside SoftwareLinkList.cpp :-> In FileToList() : Unable To Open %s File Name",ListFileName);

            return;
        }

        while (!infile.eof()){

            wchar_t * strSoftware = new wchar_t[512];

            infile.getline(strSoftware,512);

            if(wcslen(strSoftware) > 0){

                AddNode(strSoftware,0);
            }

            delete strSoftware;
        }

        infile.close();
    }

}





error C2664: '__thiscall fstream::fstream(const char *,int,int)' : cannot convert parameter 1 from 'unsigned short [260]' to 'const char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\MFC Applications\softwareinfo\SoftwareLinkList.cpp(194) : error C2664: 'class istream &__thiscall istream::getline(char *,int,char)' : cannot convert parameter 1 from 'unsigned short *' to 'char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\MFC Applications\softwareinfo\SoftwareLinkList.cpp(214) : error C2664: '__thiscall ofstream::ofstream(const char *,int,int)' : cannot convert parameter 1 from 'unsigned short [260]' to 'const char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\MFC Applications\softwareinfo\SoftwareLinkList.cpp(223) : error C2065: 'LListFile' : undeclared identifier
C:\MFC Applications\softwareinfo\SoftwareLinkList.cpp(223) : error C2297: '<<' : illegal, right operand has type 'unsigned short [1000]'

推荐答案

您必须改用wfstream.

我建议您阅读本文 [
You have to use wfstream instead.

I suggest you read this article[^]


,但随后出现错误..
未定义的变量"wfstream"
but then i am getting error..
undefined variable "wfstream"


这篇关于unicode是否支持fstream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆