Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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();
    }

}


C++
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]'
Posted

You have to use wfstream instead.

I suggest you read this article[^]
 
Share this answer
 
but then i am getting error..
undefined variable "wfstream"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900