1// here the word post is replaced by the word dak
2// POST ----> DAK
3
4#include <stdio.h>
5#include <string.h>
6
7void main ()
8{
9 char arr [100];
10 int i,j;
11
12 printf("Enter the array: ");
13 gets(arr);
14
15 for(i=0; i < strlen(arr); i++)
16 {
17 if(arr[i] == 'p' && arr[i+1] == 'o' && arr[i+2] == 's' && arr[i+3] == 't')
18 {
19 arr[i] = 'd';
20 arr[i+1] = 'a';
21 arr[i+2] = 'k';
22
23 j=i+3;
24
25 // deleting letter "t" from the word "post"
26 while(arr[j-1]!='\0')
27 {
28 arr[j] = arr[j+1];
29 j++;
30 }
31 }
32
33 }
34
35 printf("\n-------------------------------------------------------------------\n");
36 printf("Replaced string: %s\n", arr);
37 printf("-------------------------------------------------------------------\n");
38}
39
40
41
42
43
44