本文介绍了wchar的int问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
struct RCDENTRY
{
WCHAR wszRcdInd[4];
WCHAR wszTag[1];
};
.....
int nRcdNum = listbox.GetItemCount(); // CListBox
RCDENTRY *re = new RCDENTRY[nRcdNum];
...
for (int i = 0; i < nRcdNum; i++)
{
...
_itow_s(i, re[i].wszRcdInd, sizeof(re[i].wszRcdInd], 10); // this leads the program aborting
...
}
有人可以帮忙吗?
在此先感谢.
Anyone could help?
Thanks in advance.
推荐答案
sizeof(re[i].wszRcdInd]) / sizeof(WCHAR)
wszRcdInd
的大小为4个字符,可以容纳从-99到999的十进制数字字符串,后跟NULL字符.因此,您还应确保列表框中最多包含999个项目.
The size of wszRcdInd
is 4 characters which can hold decimal number strings from -99 to 999 with trailing NULL character. So you should also ensure that your list box will not contain more than 999 items.
这篇关于wchar的int问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!