Simple, but: How convert Char to String?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/07/2007 at 04:16, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.111 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi,

    I have some code that works with Char arrays... like this:

    String EncodeXOR()  
    {  
    char MyString[11]="A nice cat";  
    char MyKey[11]="ABCDEFGHIJ";  
    String ResultStr;  
    for(int x=0; x<10; x++)  
    {  
        MyString[x]=MyString[x]^MyKey[x];  
        ResultStr = ResultStr + MyString[x];  
    }  
    return ResultStr;  
    }
    

    The problem is, that MyString cannot be converted to a String, so I get errors. But anyway, they're both just a chain of characters, so there has to be a possibility.

    Is there any way to convert String to Char[n] and vice versa? Or can I just forget the whole Char thing and write a function like the one shown above that works completely with String instead of Char?

    Thanks in advance for any tips. I hope to get better in C++ so I can help one day, too :)

    Best regards,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/07/2007 at 08:15, xxxxxxxx wrote:

    you have String::GetCString() and String::SetCString() for that :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/07/2007 at 08:18, xxxxxxxx wrote:

    Hey, super. I knew it was easy. But too much doc to search in may be as bad as too little doc. At least for a beginner. Thank you!

    Cheers,
    Jack


Log in to reply