Search code examples
c++wxwidgetswxstring

Copy a part of the character array to a wxString in c++


I have an array of char like this:

char aData[100];

How can I copy only a part of aData from index from to index to in a wxString ?

Is it possible to make, with a wxString as destination and an array of char as source, something like memcpy in C ?


Solution

  • You should be able to do this using the constructor that takes the number of byts to read.

    wxString w(aData+from, to-from);
    

    for an already existing w, you could say

    w.assign(aData+from, to-from);
    

    or you could use the iterator version:

    w.assign(aData+from, aData+to);