main - #include <iostream> #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include <iostream> #include <fstream> #include <cstring> using namespace std; bool matchCheckWordsOfInterest(const char words, char cribToMatch) //function that makes sure that repeated letters in a crib correspond to repeated letters in the array { for(int k = 0; words[k] != '\0'; k++) { for(int i = 0; words[i + k] != '\0'; i++)//inner loop creates a counter to check every other position { if(cribToMatch[k] == cribToMatch[k + i])//if a character in a crib is the same as another character in the crib { if(words[k] != words[k + i])//if the corresponding 2D array characters don't match, return false return false; } } } return true;//if no issues, proceed } bool decrypt(istream& cipherstream, const char crib) { const int maxLength = 81; //assuming that the maximum length of a line is 80, +1 for the null character const int maxLines = 51; //assuming that the maximum lines is 50 char message[maxLines][maxLength]; for ( int k = 0; k < maxLines ; k++) { cipherstream.getline(message[k], maxLines); //copies each row of the cipherstream to the rows of the array } for (int row = 0; message[row][0] != '\0'; row++) cerr << message[row] << endl; for (int row = 0; message[row][0] != '\0' ; row++)//loops to make each character from the cipherstream lower case so we don't need to worry about it later { for (int column = 0; message[row][column] != '\0'; column++) { message[row][column] = tolower(message[row][column]); } } char fixedCrib[maxLength]; int fcCount = 0; int fixedCribLength = 0;...
View Full Document

Page1 / 5

main - #include <iostream> #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online