【发布时间】:2009-09-16 08:02:41
【问题描述】:
我是 C++ 新手,所以这可能是一个愚蠢的问题;我有以下功能:
#define SAFECOPYLEN(dest, src, maxlen) \
{ \
strncpy_s(dest, maxlen, src, _TRUNCATE); \
dest[maxlen-1] = '\0'; \
}
short _stdcall CreateCustomer(char* AccountNo)
{
char tmpAccountNumber[9];
SAFECOPYLEN(tmpAccountNumber, AccountNo, 9);
BSTR strAccountNumber = SysAllocStringByteLen(tmpAccountNUmber, 9);
//Continue with other stuff here.
}
当我通过这段代码进行调试时,我传入了例如帐号“A101683”。做SysAllocStringByteLen()部分的时候,账号变成了中文符号的组合...
任何人都可以对此有所了解吗?
【问题讨论】:
-
更新了 SAFECOPYLEN 定义。
标签: .net c++ visual-studio-2008 string chars