I am a newbie to C++. I am trying to write a BSTR to a CSV file, but the data when I print with wcout is not matching with data what's present in file.
BSTR tempString;
ofstream outputFile;
outputFile.open("C:\\data.csv",ios::out);
tempString = getData();
outputFile.write(tempString);
outputFile.close();
BSTR getData()
{
BSTR KBIDValue;
IStringCollection *KBID;
KBID->get_Item(0,&KBIDValue);
return KBIDValue;
}
Could some please clarify this? Also please explain what exactly is the method to write BSTR to file?
EDIT: Added code
I have added the following lines of code in my program and giving the results correctly.
ofstream outputFile;
outputFile.open(filePath,ios::out);
outputFile << W2A(CString(tempString));