Basically, we have to decode a text file back to english (Caesar Cipher), and we have to run the text file through the our progame via the Command Prompt.
I've finished writing my code, but I can't get it to feed me back any output -- wrong or right.
I don't get an error or anything just this:
(checking to see if files I need are there, they are)
+ Show Spoiler +
(running the txt file through my program, maybe?)
+ Show Spoiler +
As you can see, nothing happens, and no errors appear either.
thats how I was instructed to do it and it's worked once before the other day, but now I finished writing my code and I can't test it =/
If you feel like taking the time, you can look at that as well:
+ Show Spoiler +
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
char reverseCaesar( char ch );
char convPunct( char ch );
char convDigit( char ch );
char convRest(char ch);
//***************************************************************************************************************************
int main()
{
char ch;
int change;
cin >> ch;
while ( cin )
{
char change;
if( isalpha(ch) )
{
change = reverseCaesar(ch);
}
else if (ispunct(ch) )
{
change = convPunct(ch);
}
else if (isdigit(ch) )
{
change = convDigit(ch);
}
else
change = convRest(ch);
cin >> ch;
}
system ("pause");
return 0;
}
//***************************************************************************************************************************
char reverseCaesar( char ch )
{
int i;
if (ch <= 47 && ch > 44)
{
i = (int)ch + 23;
}
else if (ch <=99 && ch > 96)
{
i = (int)ch +23;
}
else
i = (int)ch - 3;
return char(i);
}
char convPunct( char ch )
{
switch(ch)
{
case ',': return '0';
break;
case '.': return '1';
break;
case '$': return '2';
break;
case '&': return '3';
break;
case '%': return '4';
break;
case '*': return '5';
break;
case '(': return '6';
break;
case ')': return '7';
break;
case '?': return '8';
break;
case '!': return '9';
default: return ch;
}
}
char convDigit( char ch )
{
switch(ch)
{
case '0': return '!';
break;
case '1': return ',';
break;
case '2': return ')';
break;
case '3': return '(';
break;
case '4': return '?';
break;
case '5': return '-';
break;
case '6': return '&';
break;
case '7': return '$';
break;
case '8': return '.';
break;
case '9': return '+';
break;
default: return ch;
}
}
char convRest(char ch)
{
if(ch==21)
ch='\n';
else if(ch==22)
ch=' ';
else
ch=ch;
return ch;
}
#include <iomanip>
#include <math.h>
using namespace std;
char reverseCaesar( char ch );
char convPunct( char ch );
char convDigit( char ch );
char convRest(char ch);
//***************************************************************************************************************************
int main()
{
char ch;
int change;
cin >> ch;
while ( cin )
{
char change;
if( isalpha(ch) )
{
change = reverseCaesar(ch);
}
else if (ispunct(ch) )
{
change = convPunct(ch);
}
else if (isdigit(ch) )
{
change = convDigit(ch);
}
else
change = convRest(ch);
cin >> ch;
}
system ("pause");
return 0;
}
//***************************************************************************************************************************
char reverseCaesar( char ch )
{
int i;
if (ch <= 47 && ch > 44)
{
i = (int)ch + 23;
}
else if (ch <=99 && ch > 96)
{
i = (int)ch +23;
}
else
i = (int)ch - 3;
return char(i);
}
char convPunct( char ch )
{
switch(ch)
{
case ',': return '0';
break;
case '.': return '1';
break;
case '$': return '2';
break;
case '&': return '3';
break;
case '%': return '4';
break;
case '*': return '5';
break;
case '(': return '6';
break;
case ')': return '7';
break;
case '?': return '8';
break;
case '!': return '9';
default: return ch;
}
}
char convDigit( char ch )
{
switch(ch)
{
case '0': return '!';
break;
case '1': return ',';
break;
case '2': return ')';
break;
case '3': return '(';
break;
case '4': return '?';
break;
case '5': return '-';
break;
case '6': return '&';
break;
case '7': return '$';
break;
case '8': return '.';
break;
case '9': return '+';
break;
default: return ch;
}
}
char convRest(char ch)
{
if(ch==21)
ch='\n';
else if(ch==22)
ch=' ';
else
ch=ch;
return ch;
}
I haven't added documentation, but it's fairly straight forward -- taking the characters from the txt file and decoding them (we had to write and use our own functions as well).
I'm willing to bet my program wouldn't work even if I could see it, but i'd at least like to try.
any help would appreciated, it's due in a couple of hours =)
if I have to i'll just submit and see if I can edit and resubmit tomorrow .
thanks.