I am making a Caesar cipher using c++, however when i try to compile the code my porgram breaks and claims that i have bad pointers when i am debugging
This is the code:
char* Cipher::makeCipher(int shiftInput)
{
char alphabet[] = ("abcdefghijklmnopqrstuvwxyz");
char* cipherAlphabet = NULL;
int cipherCount = 0;
int alphaCount = 0;
if (shiftInput > 26)
{
cout << "Can only shift a maximum of 25 places" << endl;
&Cipher::makeCipher;
}
cipherAlphabet[26] = '\0';
That makes no sense. Where does cipherAlphabet point when you do this?
cipherAlphabet[l] = alphabet[l] + shiftInput; This will end up writing off the end of the array named alphabet, and if you're lucky you'll get a segFault.