I'm having some trouble returning the length of a char variable in a XOR encryption code.
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int len;
string str2="A nice cat";
len = str2.size();
char str[len]=str2;
char key[len]="ABCDEFGHIJ";
for(int x=0; x<(len-1); x++)
{
str[x]=str[x]^key[x];
cout << str[x];
}
cout << "\n";
system("PAUSE");
}
I am getting the errors:
variable-sized object 'str' may not be initialized.
variable-sized object 'key' may not be initialized.
Any ideas?