Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <windows.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <stdio.h>
  7. #pragma warning(disable : 4996)
  8.  
  9. using namespace std;
  10. //void task2() {
  11. // char str[] = "Ya prosnylsya v obed privet omlet poka atlet";
  12. // char ch[] = " p";
  13. // int count = 0;
  14. // if (strstr(str, ch)) count++;
  15. // cout « count;
  16. //}
  17. //Функцию которая удаляет
  18. int main() {
  19. char str[] = "Ya prosnylsya v obed privet omlet poka atlet";
  20. char substr[] = "et";
  21. char dig[4];
  22. int i = 1;
  23.  
  24. while (strstr(str, substr))
  25. {
  26.  
  27. strncpy_s(strstr(str, substr), strlen(str), itoa(i, dig, 10), strlen(substr));
  28. i++;
  29. }
  30. cout << str;
  31.  
  32.  
  33.  
  34.  
  35. /*char s1[] = "Real Madrid Champions of Real";
  36. char s2[] = "Real";
  37. char s3[] = "Loko";
  38. char* ptr;
  39. while (strstr(s1, s2))
  40. {
  41. ptr = strstr(s1, s2);
  42. strncpy_s(ptr, 29, s3, 4);
  43. }
  44. cout << s1 << endl;*/
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement