二級指針

 1 #include
  2 #include<ctype.h>
  3 
  4 int str2int(const char* str,const char**q)
  5 {
  6         int r = 0;
  7         while(isdigit(*str))
  8         {
  9                 r = r*10+*str-'0';
 10                 ++str;
 11         }
 12         *q = str;
 13         return r;
 14 }
 15 int main()
 16 {
 17         const char* p = NULL;
 18         int n = str2int("2342asde",&p);
 19         printf("n = %d,p = %s\n",n,p);
 20         return 0;
 21 }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章