-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q43.c
45 lines (45 loc) · 951 Bytes
/
Q43.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<stdio.h>
#include<string.h>
void main(){
char frame[50][50],str[50][50];
char flag[10];
strcpy(flag,"flag");
char esc[10];
strcpy(esc,"esc");
int i,j,k=0,n;
strcpy(frame[k++],"flag");
printf("Enter no.of String :\t");
scanf("%d",&n);
printf("Enter String \n");
for(i=0;i<=n;i++)
{
gets(str[i]);
}
printf("You entered :\n");
for(i=0;i<=n;i++)
{
puts(str[i]);
}
printf("\n");
for(i=1;i<=n;i++)
{
if(strcmp(str[i],flag)!=0 && strcmp(str[i],esc)!=0)
{
strcpy(frame[k++],str[i]);
}
else
{
strcpy(frame[k++],"esc");
strcpy(frame[k++],str[i]);
}
}
strcpy(frame[k++],"flag");
//frame[k++]='\0';
printf("------------------------------\n");
printf("Byte stuffing at sender side:\n\n");
printf("------------------------------\n");
for(i=0;i<k;i++)
{
printf("%s\t",frame[i]);
}
}