自定义函数delstr()的功能是删去字符串s1中所有的"*"

运行代码:

 1 #include<iostream>
 2 using namespace std;
 3 int delstr(char *s1,char *s2)
 4 {
 5     int i=0;
 6     while(*s1!='\0')
 7     {
 8         if(*s1!='*')
 9         {*s2=*s1;s2++;i++;}
10         s1++;
11     }
12     *s2=*s1;
13         return i;
14 }
15 void main()
16 {
17     char a[]="***Hello**** Visual C++!****Hel***lo W**orld!*****";
18     char b[100];
19     int n=delstr(a,b);
20     for(int i=0;i<n;i++)
21         cout<<b[i];
22         cout<<endl;
23 }

运行结果:

本文为博主原创文章,未经博主允许不得转载。
原文地址:https://www.cnblogs.com/iamvirus/p/2568848.html