Hello everybody. I've got as homework the coding of Caesar's cipher in C++. I've created the following code. It turns out that the following letters do not work ç, ë, Ë and Ç . Does anyone have any idea?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string alphabet= "abcçdeëfghijklmno pqrstuvxyzwABCÇDEËFGHIJKLMNOPQRSTUVXYZW!#$%&'()*+,-./0123456789:;<=>?@[]_{|~}`";
int code[ alphabet.length() ];
for( int j = 0; j < alphabet.length(); j++ )
code[ j ] = j;
cout << "Hello. You can cipher your messages through the following alphabet\n";
for( int c = 0; c < alphabet.length(); c++ )
cout << alphabet[ c ] << ' ';
int continue;
cout << "\nType a number to continue. Press -1 to end: ";
cin >> continue;
int key;
cout << "Input key: ";
cin >> key;
int counter = 0;
for( int i = 0; i < text.length(); i++ )
{
for( int k = 0; k < alphabet.length(); k++ )
{
if( text[ i ] == alphabet[ k ] )
{
cipher += alphabet[ (code[ k ] + key ) % alphabet.length()];
counter++;
}
}
}
if (counter == text.length() )
{
cout << "The cipher text is: " << cipher;
}
else
cout << "The preceding text cannot be ciphered" << endl;
cout << "\nType a number to continue. Press -1 to end: ";
cin >> continue;
}
}