String to char



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

    On 29/04/2007 at 14:03, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    Platform:      
    Language(s) :

    ---------
    i could use some help :)

    im using tinyXML wrapper to write data to an xml and i need to convert a string

    String tempString = filename.GetString();

    to char (not to be confused with CHAR).

    i have NO CLUE.

    thanks in advance!



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

    On 29/04/2007 at 14:38, xxxxxxxx wrote:

    ahhh... nevermind

    :)

    solution:

    char* ExportXML::StringToChar(String s)
    {
         LONG len = s.GetCStringLen(St8bit);
         char* c = bNew CHAR[len+1];
         s.GetCString(c, len+1, St8bit);
         return c;
    }



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

    On 29/04/2007 at 17:45, xxxxxxxx wrote:

    Glad to see that you worked it out quickly! :)

    One suggestion, do this (which may prove slightly speedier if you are calling this StringToChar() often) :

    char* ExportXML::StringToChar(String s)  
    {  
         LONG len = s.GetCStringLen(St8bit)+1;  
         char* c = bNew CHAR[len];  
         s.GetCString(c, len, St8bit);  
         return c;  
    }
    

    Not much difference - but an addition here, multiplication there can have an impact in methods used very frequently. Must be from reading all of those darned 3D books where they ledger out the cost of every operation! ;)


Log in to reply