gpt4 book ai didi

c++ - 如何检查数字在 CString 中是否可用 - Visual MFC

转载 作者:行者123 更新时间:2023-11-28 06:56:40 24 4
gpt4 key购买 nike

我的程序中有一个编辑控件(类型:CString)。如何检查此控件是否包含任何数字? (例如:“abcdef4hg”、“xxxyyy12”……)

最佳答案

只是尝试检查字符串中是否有数字。您可以使用 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;
}

关于c++ - 如何检查数字在 CString 中是否可用 - Visual MFC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23063712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com