Guest User

Untitled

a guest
Jan 30th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void deleteChar(char str[], char c) {
  5.     int index = 0;
  6.     int chars = 0;
  7.  
  8.     while (str[index] != '\0') {
  9.         while (str[index+chars] == c) {
  10.             chars++;
  11.         }
  12.         str[index] = str[index+chars];
  13.  
  14.         index++;
  15.     }
  16. }
  17.  
  18. int main () {
  19.     char test[] = "cadena de pruebaaaaaaaaaaaaaaaaaaaaaaaaassssasdas";
  20.  
  21.     deleteChar(test, 'a');
  22.  
  23.     int index = 0;
  24.     while (test[index] != '\0') {
  25.         cout << test[index];
  26.         index++;
  27.     }
  28.     cout << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment