hey guy's I'm relatively new to C++ and I've been asked to make a Caesar Cipher. I'm supposed to take an encrypted .txt file and output it's decryption. I've sort of got an idea of my flow as shown below but I'm confused as to how to transform capitals in the encrypted .txt file into lower case so I can process them normally. I know I have to use "tolower", does that mean I have to include the header for it as well?
Here's my code so far, am I on the right track? I'm not seeing any errors right now but I haven't debugged yet.
/*
Assignment 06- The Caesar Cipher
Author- ******
Sources:
References:
void characterCount(char ch, int list[]);
void calcShift(int& shift, int list[]);
void writeOutput(ifstream &in, ofstream &out, int shift);
*/
#include <cstring>
#include <string>
#include <iomanip>
#include <fstream>
#include <iostream>
using namespace std;
const int CAPS_START = 65;
const int LOWER_START = 97;
int caps[26];
int lowerCase[26];
int main() {
int maxIndex;
char ch;
int intChar;
//open the file.
//streaming..
fstream testFile;
ifstream inFile;
ofstream outFile;
//Open input file
inFile.open("C:/Users/Tommy/Documents/Visual Studio 2010/Projects/a06.cpp/encrypter.txt");
if(!inFile.is_open())
{//error trigger
cout << "Error opening input file. Closing program.";
//system("PAUSE");
system("PAUSE");
return(0);
}
outFile.open("encrypter.txt");
if(!outFile.is_open())
{ //error trigger
cout << "Error opening output file. Closing Program.";
//system("PAUSE");
system("PAUSE");
return 0;
}
//read char by char to the end of the file.
//decide if the char is upper or lower.
intChar = static_cast<int>(ch); //Convert to int.
//after counting all the letters, find the max.
maxIndex = 0;
for(int i = 1; i < 26; i++)
{
if(caps[maxIndex] > caps[i])
{
maxIndex = caps[i];
}
}
system("PAUSE");
return 0;
}