Advertisement
bogdanNiculeasa

Untitled

Jan 24th, 2021
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     char s[] ="Din departare se vede tare";
  8.     char c[] = "tare";
  9.  
  10.     char *pch = strstr(s, c); // tare se vede tare
  11.     if(pch != NULL) {
  12.         while(pch != NULL) {
  13.             for(int i = 0; i < strlen(c);i++) {
  14.                 *(pch+i) = '*'; // pch este o pozitie => un pointer la pozitia
  15.             }
  16.             pch = strstr(pch, c);
  17.         }
  18.         cout << s << endl;
  19.     } else {
  20.         cout << "IMPOSIBIL";
  21.     }
  22.  
  23.     return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement