// FILE: MA61:test2c.cxx // this uses C++ stream i/o #include #include class DATALINE { public: int num; char name[23]; float balance; }; int main() { DATALINE categories[21]; int i,max; char dummy[2]; cin >> categories[0].num; i = 0; while(categories[i].num != 0) { cin.get(dummy,2); cin.get(categories[i].name,22); categories[i].name[22] = '\0'; cin >> categories[i].balance; cin.ignore(100,'\n'); //not needed when a number //on one line is followed by a number on the next i++; cin >> categories[i].num; } max = i; cout << "Number of items is " << max << endl ; for(i=0;i < max; i++) { cout << i << " " << categories[i].name << endl; } cout << "that's all folks!" << endl; return 0; }