运行代码:
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 }
运行结果: