判断字符串是否为数字
来源:互联网 发布:阿里云 centos7 mysql 编辑:程序博客网 时间:2024/06/15 18:03
//判断字符窜是否为数字BOOL IsStringNum(const CString &strNum ){ CString strCheck = strNum; strCheck.TrimLeft(); strCheck.TrimRight(); if(strCheck.IsEmpty()) return FALSE; ///////////////////////////////////////////// char chCheck; for(int i = 0; i < strCheck.GetLength(); i++) { chCheck = strCheck.GetAt(i); if(!::IsCharAlphaNumeric(chCheck)) return FALSE; if(::IsCharAlpha(chCheck)) return FALSE; } return TRUE;}
BOOL IsStringFloat(const CString &strNum){ CString strCheck = strNum; strCheck.TrimLeft(); strCheck.TrimRight(); if(strCheck.GetLength() == 0) return FALSE; ///////////////////////////////////////////// if(strCheck.GetAt(0) == '.' || strCheck.GetAt(strCheck.GetLength() - 1) == '.') return FALSE; ///////////////////////////////////////////// char chCheck; int iDotCount = 0; BOOL bCountDot = FALSE; int iAfterDotNum = 0; for(int iIndex = 0; iIndex < strCheck.GetLength(); iIndex++) { chCheck = strCheck.GetAt(iIndex); switch(chCheck) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { if(bCountDot) { iAfterDotNum++; if(iAfterDotNum > 2) return FALSE; } break; } case '.': { iDotCount++; bCountDot = TRUE; if(iDotCount > 1) return FALSE; break; } case '-': { if(iIndex != 0) return FALSE; break; } default: { return FALSE; } } } return TRUE;}
0 0
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- 判断字符串是否为数字
- JAVA wait(), notify(),sleep详解
- MYSQL培训经典教程读书笔记
- HDU 4912 Paths on the tree LCA 排序贪心
- 移植Qt图形界面应用程序到S3C2440 arm开发板
- 【Google Glass应用开发】 3. 运行应用
- 判断字符串是否为数字
- C2 Debug设置
- eclipse中将代码中某个相同的内容全部替换
- hd 2040 亲和数
- 设计模式7—Prototype设计模式
- HDU 4915 Parenthese sequence _(:зゝ∠)_ 呵呵
- 批量创建用户和邮箱
- 《有点失望》的经过及其背后意义
- 混合语言的游戏开发系统架构