[英]How to check number is available in CString - Visual MFC
There is an edit control (Type: CString) in my program. 我的程序中有一个编辑控件(类型:CString)。 How to check if this control contains any number?
如何检查此控件是否包含任何数字? (ex: "abcdef4hg", "xxxyyy12"....)
(例如:“ abcdef4hg”,“ xxxyyy12” ....)
Just try to check if there is a digit in the string or not. 只需尝试检查字符串中是否有数字。 You can use
std::isdigit
. 您可以使用
std::isdigit
。
#include <cctype>
bool hasDigits(const CString &str)
{
for(int i = 0; i < str.GetLength(); i++)
{
if(std::isdigit(str[i]))
return true;
}
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.