c++ - Fill a WCHAR array with filepaths -
I fill a WCHAR array with text file for textures in C ++ Trying but I have difficulty understanding how to do this.
How do I do this now:
WCHAR voltaactactor [] = {l "../ engine / data / wall 01.dds", l "../ Engine / data / wall02.dds "}; And it is not compiled at all. If I do this with only one file path, then it fills every single pointer of the array with a single character and I need the voltexation array [0] so that there is a complete file path and so on.
Thanks in Advance.
With this definition:
WCHAR welding around [ ] = {...
You have defined an array of WCHAR , that is, string
If you want array of arrays , you can define an array of indicator WCHAR s :
CONST WCARAR * WALLELECTECLES OTHER [] = {L "../Engan / Data / Wall01.Disk", L. ../ engine / Data / Wall02.Didz "}; (Since these strings are literal and you can not modify them, I have added const .)
Note that in modern C ++ you want to use a convenient container class instead of a raw c-style array like std :: vector and std :: Wstring for WCHAR -serial string, e.g.
#include & lt; String & gt; // std :: wstring for #include & lt; Vector & gt; // std :: vector for .... std :: vector & lt; Std :: wstring & gt; Waltectarrere = {l "../ engine / data / wall01.disc", l "../ engine / data / wall02.edes"}; You can access a string in the array using the normal [] syntax (like WallTextureArray [0] The first string, Voltaicaceres [1] is the second string, etc.).
In addition, a std :: wstring is given, if you need an indicator, the raw C-style NUL-terminated string (for example, the interop with C API ), You can call the std :: wstring :: c_str () method.
You can also add more strings to vector, e.g. Using the std :: vector :: push_back () method:
VoltageArrayPush_Back (L. ../ engine / data / other_wall.disk ");
Comments
Post a Comment