vc 字符串的处理函数

1.读Edit控件里的内容:                               
   char m[20];                            
   GetDlgItemText(ID,m,5);///////////////将地址为ID的控件里的内容的的前4位放进字符数组m中         
                       ////// int GetDlgItemText( int nID , CString& rString ) const;这是另一种用法                  
   MessageBox(m,"11",0);//输出m
2.判断字符数组中字符的个数                     
                      char data[] = "This is a true story.";/////第一一个字符数组             
                              char * p = data;///指向data的字符指针  (p是地址,*p是内容)                      
                     int i=0;////////用来计算字符的个数                                      
     while(*p!=0)/////////////判断结尾字读0在哪个位上                         
                  {i++;p++;}     该程序可用函数实现:                         
                int  len;                              
   len = strlen(data);
3.用MessageBox显示刚才的字符数组的长度           
      char display[10];                                                              
  sprintf( display , "%d" , len );/////////////////将len以十进制放进display里                                                           
     MessageBox(display,"显示字符数组的长度",0);

你可能感兴趣的:(vc 字符串的处理函数)