I have an encryption assignment that takes input to create a key and another input to create a message, then taking the values of the key, it adds them to the message in such a way that the message will become a code. So if the message is "crow" and the key is "abcd" the new message, or code will be "csqz"

I have gotten everything to work correctly except that I run into problems if the message is longer than the key. Last week I had the same type of assignment but we got to write it in C++ so to make sure the key would repeat itself until it was as long as the message I did this:

Code:
while (s.length() > k.length())
        {
            k = k+k;
        }
*note, k is the string that has been chosen through user input as the key
* s.length is the number of characters in the message and k.length is the number of characters in the key

However, I tried the same type of thing in C and it does not work:

Code:
while (keyLength<messageLength)
        {
            key = key + key;
        }
*note, key is the string representing the input key and message is the string representing the input message

I get the compiler error (I'm using GCC):

"invalid operands to binary +"

If anybody has a solution that would fix this problem that would be great.

Thanks