#include #include // for ifstream #include "CPstring.h" #include "prompt.h" #include "vector.h" // file: transl.cc // author Dietolf Ramm; date: 11/4/96 // read text, as characters, modify with translate table // print out bool LoadCode(Vector & code) // postcondition: code contains a translate table and returns true // or returns an error code of false { int k = 0; char c; ifstream init; init.open("Translate"); while (init.get(c)) { code[k] = c; k++; } return k == 257; // allow for newline at end of line } int main() { Vector code(257); // allow for newline at end if (LoadCode(code) != true) { cout << "Code loading error. Aborted." << endl; exit(1); } string filename = PromptString("Enter name of input file: "); ifstream inchar; inchar.open(filename); char c, lastc = ' '; while (inchar.get(c)) { cout << code[c] << " "; if (c == ' ' && lastc != ' ') cout << endl; lastc = c; } cout << endl; return 0; } Sample output: transl Enter name of input file: honor.short a N E S S E N T I A L F E A T U R E O F d U K E u N I V E R S I T Y I S I T S C O M M I T M E N T T O I N T E G R I T Y A N D E T H I C A L C O N D U C T cat Translate abcdefghijklmnopqrstuvwxya ABCDEFGHIJKLMNOPQRSTUVWXYA