I created a program which takes a 'word' and a num parameter as the shifting number. Example if the string is Caesar Cipher
and num is 2 the output should be Ecguct Ekrjgt
. But I want the punctuation, spaces, and capitalization to remain intact. Also I can't add a sentence. Just a word. I am not allowed to use strings.
#include<iostream>
using namespace std;
int main()
{
char name[50] = { '\0' };
int cipherKey, len;
cout << "Enter cipher key: ";
cin >> cipherKey;
cout << "Enter a message to encrypt: ";
cin >> name;
len = strlen(name); // this code just inputs the length of a word. after spaces it won't calculate.
for (int i = 0; i < len; i++)
{
char temp = name[i] + cipherKey;
cout << temp;
}
cout << "\n\n";
return 0;
}