首页 > 编程语言 > 详细

C语言:将形参s所指字符串中所有ASCII码值小于97的字符存入形参t所指字符数组中,

时间:2019-03-14 18:33:52      阅读:257      评论:0      收藏:0      [点我收藏+]

//将形参s所指字符串中所有ASCII码值小于97的字符存入形参t所指字符数组中,形成一个新串,并统计出符合条件的字符个数返回。

//关注点:使用*(t+n)的方式可以不改变指针的指向,像数组一样处理指针。

 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 }

 

C语言:将形参s所指字符串中所有ASCII码值小于97的字符存入形参t所指字符数组中,

原文:https://www.cnblogs.com/ming-4/p/10532118.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!