请看一下你的声明的是TCHAR类型,strlen的原型是:size_t strlen( const char *string ); TCHAR: typedef char TCHAR; For Unicode platforms, TCHAR is defined as synonymous with the WCHAR type. 所以,根据你的环境,用wcslen试试吧
'wcslen' : cannot convert parameter 1 from 'char [19]' to 'const unsigned short *' 貌似还是搞不出来啊。我现在就想得到用户输入的字母或数字个数。谁能帮忙写个…… 我用的是vc 6.0
UINT GetDlgItemText( HWND hDlg, int nIDDlgItem, LPTSTR lpString, int nMaxCount ); If the function succeeds, the return value specifies the number of TCHARs copied to the buffer, not including the terminating NULL character.
得到的
STR1 0X0012fb70 "1234"
temp -858993460
int temp;
GetDlgItemText(hwnd,IDC_EDIT1,STR1,sizeof(STR1));
temp=strlen(STR1);
我是这么写的。现在就是想得到输入的字符个数。。
若是char*类型的话,应该是没问题呢
TCHAR STR1[MAX_COUNT];
int temp;
GetDlgItemText(hwnd,IDC_EDIT1,STR1,MAX_COUNT);
temp=_tcslen(STR1);
_tcslen(STR1); //这样怎么样?
const int MaxLen = 128;
CString STR1;
GetDlgItemText( IDC_EDIT1, STR1, MaxLen );
int temp = STR1.GetLength();这个应该可以哦
Microsoft Visual C++ 6.0
。
9楼高人写的是Unicode工程,好像要加什么头文件吧,呵呵这个不熟悉
请看一下你的声明的是TCHAR类型,strlen的原型是:size_t strlen( const char *string );
TCHAR:
typedef char TCHAR;
For Unicode platforms, TCHAR is defined as synonymous with the WCHAR type.
所以,根据你的环境,用wcslen试试吧
貌似还是搞不出来啊。我现在就想得到用户输入的字母或数字个数。谁能帮忙写个……
我用的是vc 6.0
int nIDDlgItem,
LPTSTR lpString,
int nMaxCount
);
If the function succeeds, the return value specifies the number of TCHARs copied to the buffer, not including the terminating NULL character.
然后在函数中:
CString CxxxDlg::GetValue()
{
UpdateData(true);
int temp = m_edt1.GetLength();
return m_edt1;
}
GetDlgItemText(IDC_, str1);
int temp = str.GetLength();
//试试这个
int nIDDlgItem,
LPTSTR lpString,
int nMaxCount
); 返回值是不是就是你想要的的数据呢?