I’m trying to initialize a combo box with the content of an INI file. Each line of the file contains a name for a website and the path to that site, tab delimited.
I’m trying to read the file into a list so I can sort it etc.
Visual studio won’t let me use a struct in a managed class:
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
using namespace std;
struct website {
std::string name;
std::string path;
} newsite;
std::list<website> websites;
string line;
ifstream myfile ("HowToInit.ini");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
size_t tabpoint = line.find_first_of('\t');
newsite.name = line.substr(0,tabpoint).c_str();
newsite.path = line.substr(tabpoint).c_str();
}
myfile.close();
}
else
{
// create dummy file here
}
this->comboBox1->SelectedIndex = 2;
}
I also tried using a std::pair<string,string>, but it won’t accept the first and second notation either.
What is the correct coding for something like this?