动态wchar_t的阵列(C ++初学者) [英] Dynamic wchar_t array (C++ beginner)

查看:119
本文介绍了动态wchar_t的阵列(C ++初学者)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我修改了一些C ++ code,有一个 wchar_t的myArray的[MAX_PATH] 在头文件。

I am modifying some C++ code that has a wchar_t myArray[MAX_PATH] in the header file.

我的修改意味着,我不知道这阵,直到运行时的长度。我怎么能存储动态长度的数组呢?也许我只是保持一个 wchar_t的* 在头文件和另一个 INT 持有其长度?

My modifications mean that I cannot know the length of this array until runtime. How can I store an array of dynamic length instead? Maybe I just keep a wchar_t* in the header file and another int to hold its length?

推荐答案

使用的std :: wstring的来代替。这是一个包含动态字符串 wchar_t的

Use std::wstring instead. It's a dynamic string containing wchar_t.

这篇关于动态wchar_t的阵列(C ++初学者)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆