我正在尝试在结构中搜索我输入的值。但是,即使我只输入单词的一部分,我也希望搜索能够正常工作。我该怎么做呢?
这是我的代码:
for (int i = 0; i < size; i++)
{
if (searchName == ptrCandy[i].name)
{
cout << "Name: " << ptrCandy[i].name << "\n" << "Quantity: " << ptrCandy[i].quantity;
cout << "\n" << fixed << setprecision(2) << "Cost: $" << ptrCandy[i].cost << "\n" << endl;
}
}