Gistrec

ОП допуск к РГЗ 4

Dec 9th, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void) {
  5.     char text[40] = "00123000123000";
  6.     text[39] = '\0';
  7.    
  8.     int i;
  9.     char *pos = text[0];
  10.     for (i = 0; i < 10; i++) printf("%c", text[i]);
  11.     printf("\n");
  12.     // Нужно чтобы поиск был с последнего вхождения!
  13.     while (pos = strstr(&pos, "123")){
  14.         //pos = strstr(text, "1");
  15.         *pos = '0';
  16.         *(pos+1) = '0';
  17.         *(pos+2) = '0';
  18.     }
  19.  
  20.     for (i = 0; i < 10; i++) printf("%c", text[i]);
  21.     /*pos =
  22.     *pos = '0';
  23.     printf("%c", text[2]);*/
  24. }
Advertisement
Add Comment
Please, Sign In to add comment