#include "library.h" struct element { string symbol, name; double atwt; }; bool lookup(string query, element els[], const int size, element & answer) { for (int i=0; i> table[howmany].symbol >> table[howmany].name >> table[howmany].atwt; if (elf.fail()) break; howmany += 1; } elf.close(); cout << "Read " << howmany << " elements\n"; while (true) { double total = 0.0; cout << "> "; while (true) { string sym = readsymbol(); if (sym == end_of_line) break; element it; if (lookup(sym, table, howmany, it)==false) cerr << it.symbol << " " << "Not found\n"; else { cout << it.symbol << " " << it.name << " " << it.atwt << "\n"; total += it.atwt; } } cout << "total is " << total << "\n"; } }