[indignant]
harumph ()
[/indignant]
I finally got my code to work. Just uncomment out the lines that are commented to add back in the functionality that i don't have, if they are needed.
Code:
#include <iostream>
#include <conio.h> // getche();
int main(int argc, char *argv[])
{
char sInput[1024];
int iLength = 0;
int i = 0, x = 0, y = 0, z = 0;
cout << "What message do you want to scramble?\n";
cin.get(sInput, 1024);
//cin.ignore(1024, '\n'); // Do you really need this?
iLength = strlen(sInput);
int half = iLength/2;
//strrev(sInput); // I don't have this function, sorry.
char *sOutput = new char[iLength];
for(int p=0;p<iLength;p++)sOutput[p]='-';
sOutput[iLength]='\0';
for (i=0, x=0; (i<iLength) && (sInput[x] != '\0'); i++, x=i/2){
if (i%2==0){
sOutput[half+x]=sInput[i];
} else {
sOutput[x]=sInput[i];
}
}
cout << "Scrambled: " << sOutput << endl;
for (i=0, x=0; (i<iLength) && (sInput[x] != '\0'); i++, x=i/2){
if (i%2==0){
sInput[i]=sOutput[half+x];
} else {
sInput[i]=sOutput[x];
}
}
cout << "Descrambled: " << sInput << endl;
if (getche());
return 0;
}
~Inquirer