提取CString中的数字

 

C++代码
  1. GPSLocation = "676°88′0″E,0°77′0″N";  
  2.   
  3.     CNewBox CallGPS;  
  4.   
  5.     int nLen = GPSLocation.GetLength();  
  6.     CString strLs[5];
  7.     int Num[5];
  8.   
  9.     CString strTemp;  
  10.     int n = 0;  
  11.   
  12.     forint i=0; i <=nLen; i++ )  
  13.     {  
  14.         CString str = GPSLocation.Mid(i,1);  
  15.         if( str>=L"0" && str <=L"9" )  
  16.         {  
  17.             strTemp += str;  
  18.         }  
  19.         else  
  20.             {  
  21.                 if( strTemp != "" && n<=4 )  
  22.                 {  
  23.                     strLs[n] = strTemp;  
  24.                     strTemp = ""
  25.                     Num[n]=  _wtoi(  (wchar_t *)strLs[n].GetBuffer(strLs[n].GetLength())  ); 
  26.                     n++;    
  27.                       
  28.                 }  
  29.             }  
  30.     }  
  31.   
  32.   

就全用代码说话吧。

Tags: vc

« 上一篇 | 下一篇 »

Trackbacks

发表评论

评论内容 (必填):