//將形參s所指字符串中全部ASCII碼值小於97的字符存入形參t所指字符數組中,造成一個新串,並統計出符合條件的字符個數返回。數組
//關注點:使用*(t+n)的方式能夠不改變指針的指向,像數組同樣處理指針。less
1 #include <stdio.h> 2 int fun(char *s, char *t) 3 { int n=0; 4 while(*s) 5 { if(*s < 97) { 6 /**********found**********/ 7 *(t+n)= *s ; n++; } 8 /**********found**********/ 9 s++ ; 10 } 11 *(t+n)=0; 12 /**********found**********/ 13 return n ; 14 } 15 void main() 16 { char s[81],t[81]; int n; 17 printf("\nEnter a string:\n"); gets(s); 18 n=fun(s,t); 19 printf("\nThere are %d letter which ASCII code is less than 97: %s\n",n,t); 20 }