簡體   English   中英

如何檢查CString中可用的數字-Visual MFC

[英]How to check number is available in CString - Visual MFC

我的程序中有一個編輯控件(類型: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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM