Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string.h>
- using namespace std;
- void deleteChar(char a[], char c)
- {
- int length=strlen(a);
- for (int i=0;i<length;i++)
- {
- if (a[i]==c)
- {
- for( int j=i;j<length-1;j++) //смещаем символы правее i-ого влево
- {
- a[j]=a[j+1];
- }
- length--;// так как произошло смещение ,длина уменьшилась
- i--;// из за смещения i-ый индекс нужно пройти еще раз
- }
- }
- a[length]=0;
- }
- int main()
- {
- char str[100]="Hello my name is Ilia, i live in England, i drink lipton;";
- deleteChar(str,'l');
- cout<<str;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement