dumb question about String

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TGF

    #1

    dumb question about String

    How do you copy a String type into a native char buffer[256]? Dumb
    question, but not sure how to do it :(

    TGF



  • nn

    #2
    dumb question about String

    Hello,

    Use ToCharArray method of String.

    Regards[color=blue]
    >-----Original Message-----
    >How do you copy a String type into a native char buffer[/color]
    [256]? Dumb[color=blue]
    >question, but not sure how to do it :(
    >
    >TGF
    >
    >
    >
    >.
    >[/color]

    Comment

    • Tomas Restrepo \(MVP\)

      #3
      Re: dumb question about String

      TGF,[color=blue]
      > How do you copy a String type into a native char buffer[256]? Dumb
      > question, but not sure how to do it :([/color]

      If you don't mind an extra buffer copy, you can use the Marshal class in the
      System::Runtime ::InteropServic es namespace, with the StringToAnsiHGl obal(),
      then just use strncpy or another like method.

      Otherwise, another option would be to use PtrToStringChar s() in vcclr.h, pin
      the returned pointer, and then use a Unicode-to-ansi conversion function
      (such as WideCharToMulti Byte) directly unto your array.

      --
      Tomas Restrepo
      tomasr@mvps.org


      Comment

      Working...