本文整理汇总了C++中table::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ table::insert方法的具体用法?C++ table::insert怎么用?C++ table::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table
的用法示例。
在下文中一共展示了table::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_activities
// Loads activitiess from external file "activities.txt"
// into the hash table.
int load_activities(activities & to_add, table & hash )
{
ifstream fin;
char * name = new char[45];
char * description = new char[150];
char * location = new char[21];
int difficulty = 0;
char gear = 'Y';
char * key;
fin.open("activities.txt");
if(fin)
{
fin.get(name,45, ':');
while(!fin.eof())
{
fin.ignore(100,':');
fin.get(description, 150, ':');
fin.ignore(150,':');
fin.get(location, 21, ':');
fin.ignore(100,':');
fin >> difficulty;
fin.ignore(100,':');
fin >> gear;
fin.ignore(100,'\n');
key = new char[strlen(location) +1];
strcpy(key, location);
to_add.add_activities(name, description, location, difficulty, gear);
hash.insert(key, to_add);
delete [] key;
name = new char[45];
description = new char[150];
location = new char[21];
fin.get(name,45, ':');
}
}fin.close();
return 1;
}