Basically all this program does, is take in a string from the user, then the amount of letters they want it to skip, then it outputs it. Basically what it does, is it goes through every char in the string, then sets it to it's ascii value, adds the shift value onto it, and then makes it back into a char and outputs it. Very simple, yet cool if you want to send easily decoded messages to your friends Big Grin

Here's the code,

Code:

#include <iostream>
#include <string>
using namespace std;

int main()
{
   string line = ""; // string that stores the sentence
   int lineLength = 0; // length of the string
   int shiftValue = 0; // how many letters we are going to skip
   int *asciiValue; // pointer so that we can delete it to avoid memory leaks
   char *cipherLine; // pointer so that we can delete it to avoid memory leaks

   cout << "Enter a string: "; // prompts user for string
   getline(cin, line); // sets it to the string line
   cout << "Please enter a shift value: "; // asks for a shift value
   cin >> shiftValue; // sets it to the shiftValue int
   lineLength = line.length() - 1; // sets lineLength = to the length of the string minus 1
   asciiValue = new int[line.length()]; // redifines asciiValue to an array with the amount of chars in line
   cipherLine = new char[line.length()]; // redifines cipherValue to an array with the amount of chars in line
   for (int i = 0; i <= lineLength; i++) // for loop to loop through every char in line
   {
      asciiValue[i] = (int)line[i]; // sets asciiValue to the int value of the char its on
      asciiValue[i] += shiftValue; // makes adds the shift value to asciiValue, which is now an int
      cipherLine[i] = (char)asciiValue[i]; // sets cipherLine to the char value of asciiLine
      cout << cipherLine[i]; // outputs that character on the screen, and keeps looping until all chars have been done
   }
   delete cipherLine; // delete the pointer to avoid memory leaks
   delete asciiValue; // delete the pointer to avoid memory leaks
   cout << endl;
   system("pause");
   return 0; // end the program
}


Hope you guys enjoy Big Grin