decrypt

decrypt - #include #include #include...

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

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> #include <cctype> using namespace std; const int MAXCHAR = 81; const int MAXLINES = 50; void processCrib(char processedCrib[], const char crib[]) { int j = 0; int i = j; int k = 0; for (j=0; j<strlen(crib); j++) { if (isalpha(crib[j]) == true) { processedCrib[k] = crib[j]; } if (isalpha(crib[j]) == false) //how to get rid of extra spaces { processedCrib[k] = ' '; for (i = 1; isalpha(crib[j+i]) == false; i++); //check to see if there are multiple non alphas j= j+i-1; } k++; } for (j=k; j<strlen(crib); j++) { processedCrib[k]='\0'; } if (processedCrib[0] == ' ') //if the first thing is a space then it gets rid of it. { for (j=0; j<=strlen(processedCrib); j++) { processedCrib[j]=processedCrib[j+1]; } } for (i=0; i<strlen(processedCrib); i++) processedCrib[i] = tolower(processedCrib[i]); } void processMessage(char newMessage[][MAXCHAR], const char message[][MAXCHAR], int lineCount) { int j = 0; int i = j; int k = 0; int liner = 0; while (liner<lineCount) { for (j=0; j<strlen(message[liner]); j++) { if (isalpha(message[liner][j]) == true) {
Background image of page 1

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

View Full DocumentRight Arrow Icon
newMessage[liner][k] = message[liner][j]; } if (isalpha(message[liner][j]) == false) { newMessage[liner][k] = ' '; for (i = 1; isalpha(message[liner][j+i]) == false; i++); //check to see if there are multiple non alphas j= j+i-1; } k++; } for (j=k; j<strlen(message[liner]); j++) newMessage[liner][k]='\0'; for (i=0; i<strlen(newMessage[liner]); i++) newMessage[liner][i] = tolower(newMessage[liner][i]); k=0; liner++; } }
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/10/2011 for the course CS 31 taught by Professor Melkanoff during the Spring '00 term at UCLA.

Page1 / 6

decrypt - #include #include #include...

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

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