Qt 判斷QString中的字符串是否為純數字


 1 /*** 
 2   *判斷一個字符串是否為純數字 
 3   */  
 4 int Common::isDigitStr(QString src)  
 5 {  
 6     QByteArray ba = src.toLatin1();//QString 轉換為 char*  
 7      const char *s = ba.data();  
 8   
 9     while(*s && *s>='0' && *s<='9') s++;  
10   
11     if (*s)  
12     { //不是純數字  
13         return -1;  
14     }  
15     else  
16     { //純數字  
17         return 0;  
18     }  
19 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM