Advertisement
markkoval1999

Untitled

Nov 30th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4. int main()
  5. {
  6.     int i = 0;
  7.     char haupt[100];
  8.     char search[20];
  9.     char change[20];
  10.     char mas[10][10];
  11.     char result[100];
  12.     char limit[] = " ,-''";
  13.     printf("Enter the sentence\n");
  14.     fgets(haupt, 99, stdin);
  15.     printf("word to search: ");
  16.     scanf("%s",&search);
  17.     printf("for what change\n");
  18.     scanf("%s",&change);
  19.     char *broke;
  20.     broke = strtok(haupt, limit);
  21.     while (broke != NULL)
  22.     {
  23.         strcpy(mas[i], broke);
  24.         broke = strtok(NULL, limit);
  25.         i++;
  26.     }
  27.     printf("%d\n",i);
  28.     for(int j = 0; j < i; j++)
  29.     {
  30.         if (strcmp(mas[j], search) != 0)
  31.         {
  32.             strcat(result, mas[j]);
  33.         }
  34.         else if (strcmp(mas[j], search) == 0)
  35.         {
  36.             strcat(result, change);
  37.         }
  38.     }
  39.     /*for (int j = 0; j<i; j++)
  40.     {
  41.         printf("%s\n", mas[j]);
  42.     }*/
  43.    
  44.     printf("%s\n", result);
  45.    
  46.     getchar();
  47.     getchar();
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement