If you read the _bstr_t
documentation, you will see that its assignment operator takes a normal const char *
.
So it's probably just to assign to it:
_bstr_t sPassword;
// ...
sPassword = sTemp.c_str();
If you have trouble using normal narrow-character strings, you should convert all your code relating to this to use wide-character string, i.e. the classes with the w
prefix:
std::wifstream inFile("QdatPassWordconfig.config");
_bstr_t sPassword;
std::wstring sTemp;
if (inFile.is_open())
{
if(std::getline(inFile, sTemp))
{
std::wcout << sTemp << endl;
sPassword = sTemp.c_str();
}
}