The second day I try to make encryption Xor'om, but it still does not work. Here is my code. What is wrong with me?
#include "stdafx.h" #include <iostream> #include <Windows.h> #include <string> using namespace std; int main() { SetConsoleCP(1251); SetConsoleOutputCP(1251); int key; char text[100]; string res; cout << "ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΠ΅ΠΊΡΡ: " << endl; // Π²Π²ΠΎΠΆΡ ΡΠ΅ΠΊΡΡ cin >> text; cout << "ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΊΠ»ΡΡ: " << endl; cin >> key; // Π²Π²ΠΎΠΆΡ ΠΊΠ»ΡΡ for (int i = 0; i < strlen(text); i++) { // ΠΏΠΎΠ΄Π³ΠΎΠ½ΡΡ ΡΠ°Π·ΠΌΠ΅Ρ res[i] = text[i] ^ key; //ΡΠ°ΠΌΠΎ ΡΠΈΡΡΠΎΠ²Π°Π½ΠΈΠ΅ } cout << "ΠΠ°ΡΠΈΡΡΠΎΠ²Π°Π½Π½ΡΠΉ ΡΠ΅ΠΊΡΡ: " << res << endl; return 0; }
resmemory would be allocated - Anton Shchyrovstringtype. And do you need to simultaneously store the original string and the encrypted? - Anton Shchyrov