0
Hi sololearners, im trying to encrypt a sentence with ceaser cypher in c++ but I'm facing problem in this
string str; getline(cin,str) For(int i=0;(i<str.length()&&str[i]!='\0');i++) { str[i]='a'-str[i]+'z'; cout<<str; } this only encryping one string before space.
1 Answer
+ 2
1) take cout<<str out of the loop.
2) handel the space also
Here the fixđ
https://code.sololearn.com/ccRUC1X94iIc/?ref=app
Also looks like you are using a static key = -1 to encipher the text. Generally in Ceaser cypher, we use randomly generated key or ask the key from the user to make the encryptions stronger.