|
|
1.1 ! root 1: // list test program. Takes one argument, reads standard input. ! 2: // removes copies of argument from input ! 3: ! 4: #include "String.h" ! 5: #include "list.h" ! 6: ! 7: listdeclare(String) ! 8: listoutimplement(String) ! 9: ! 10: String_list ! 11: remove(String s, String_list ls) ! 12: { ! 13: String_list_iterator it(ls); ! 14: String temp; ! 15: while ( it.nextX(temp) ) { ! 16: if ( temp == s ) { ! 17: it.remove(); ! 18: } ! 19: } ! 20: return ls; ! 21: } ! 22: ! 23: ! 24: main(int argc, char **argv) ! 25: { ! 26: String_list s_list; ! 27: String temp; ! 28: if ( argc != 2 ) { ! 29: cout << "must supply an arg\n"; ! 30: exit(1); ! 31: } ! 32: String arg(argv[1]); ! 33: while ( cin >> temp) ! 34: s_list.put(temp); ! 35: cout << remove(arg, s_list) << "\n"; ! 36: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.