?
2009-11-20 05:22:03 UTC
Here is a part of my code :
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
DWORD drives = GetLogicalDrives();
int mask = 0;
char drv;
string sDrv;
for(int i=1;i<=26;i++){
mask = int(Math::Pow(2.0, i));
if(drives & mask){
drv = 'A'+i;
sprintf(sDrv, "%c:\\", drv);
this->cdCombo->Items->Add(sDrv);
}
}
}
========================================================================
when compiling, i got these error messages :
1>c:\users\sxstrat\documents\visual studio 2010\projects\conv\conv\Form1.h(148): error C2664: 'sprintf' : cannot convert parameter 1 from 'std::string' to 'char *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\sxstrat\documents\visual studio 2010\projects\conv\conv\Form1.h(149): error C2664: 'System::Windows::Forms::ComboBox::ObjectCollection::Add' : cannot convert parameter 1 from 'std::string' to 'System::Object ^'
1> No user-defined-conversion operator available, or
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========================================================================
i dont really understand why the sprintf function cannot do the conversion, and why the System::Windows::Forms::ComboBox::ObjectCollection::Add cannot add value of type string. FYI, i already #include
========================================================================
anyone have the solution?
BTW, im using VC++ 2010 Express