if (('a' <= ch) && (ch <= 'z')) A[ch - 'a'] += 1;
To find percentages of each letter in the text, compute the total
number of letters in the message as you read it or by adding up the frequencies.
Divide the number of occurences of a letter by the total to get the percentage.
// Get name of old (encrypted) file if (SelectOldFileName(InFileName) // InFileName is of type string // get file name of new file if (SelectNewFileName(OutFileName) if (OpenFile(InFile, InFileName, textread) if (OpenFile(OutFile, OutFileName, textwrite) { while (InFile.get(ch)) { transform the data item, ch send zero, one, or more new items of data to OutFile } { close both files } InFile.close(); OutFile.close(); }
Notice that this code asks the user for the name of the old file, then if the user has not clicked CANCEL this code asks for the name of the new file, then if the user has not clicked CANCEL the work on the two files begins.
Last Updated: September 21, 1998 8:22 pm by