rightyo, something i absolutley hate in C++ (being a PHP programmer at heart ) is pointers and memory issues. every time i think i've understood when to use * or &, i try to compile and end up taking it off anyways, thats not the problem. problem is that when i run this code, it crashs my computer. now to my understanding(which came a bit after) what happend was that XORing a memory adress made it crash. but even with all the * and () stuck every which way, i can't get it to work could someone correct this and explain whats wrong. cheers
Code:
#include <iostream.h>
#include <string.h>
char * encrypt(char * input, char * key)
{
for (int i=0; i<=strlen(input);i++)
{
for (int u=0; u<=strlen(key);u++)
{
//cout<<input[i]<<endl;
input[i] = input[i] ^ key[u];
}
}
return(input);
}
int main()
{
char * message = "hell, this is a bangin message";
char * key = "this is a bangin key";
message = encrypt(message, key);
cout<<message<<endl<<endl;
message = encrypt(message, key);
cout<<message<<endl<<endl;
cin.get();
}