C++ error - returning a char array

Posted by Yosy on Stack Overflow See other posts from Stack Overflow or by Yosy
Published on 2011-01-17T18:43:33Z Indexed on 2011/01/17 18:53 UTC
Read the original article Hit count: 171

Filed under:
|

Consider the following code:

char CeaserCrypt(char str[256],int key)
{
    char encrypted[256],encryptedChar;
    int currentAsci;

    encrypted[0] = '\0'; 

    for(int i = 0; i < strlen(str); i++) 
    {
        currentAsci = (int)str[i];
        encryptedChar = (char)(currentAsci+key);
        encrypted[i] = encryptedChar;
    }

    return encrypted;
}

Visual Studio 2010 gives an error because the function returns an array. What should I do?

My friend told me to change the signature to void CeaserCrypt(char str[256], char encrypted[256], int key). But I don't think that is correct. How can I get rid of the compile error?

© Stack Overflow or respective owner

Related posts about c++

Related posts about c