Program for character stuffing

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

INPUT:
enter string:
asdlefgh
enter position: 8
invalid position,enter again: 3
enter the character: k

OUTPUT:
frame after stuffing:
dlestx as dle k dle dle dlefgh dleetx

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;
char a[20],b[50],ch;
clrscr();
printf("enter string\n");
scanf("%s",&a);
n=strlen(a);
printf("enter position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position, Enter again :");
scanf("%d",&pos);
}
printf("enter the character\n");
ch=getche();
 
b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;
while(i<n)
{
if(i==pos-1)
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
}
if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
j=j+3;
}
 
b[j]=a[i];
i++;
j++;
}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\nframe after stuffing:\n");
printf("%s",b);
getch();
}

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

9 Responses to “Program for character stuffing”

  1. good code.Easy to understand.

    Can you please send the program for bit stuffing and character stuffing
    program in java using client-server communication ie if client is stuffing
    the bit(as it is sender) then server will un stuff that bits (as it is receiver)
    (plz send soon)

    Reply
  2. There is such good and easy codding for understanding…
    But, why we used “d, l, & e” characters for this codding..?..
    Can we codding this program without that characters..?

    Reply
  3. Plz send the program bit stuffing and character stuffing in java to my mail

    Reply
  4. ashita garg

    plz send the program of bit and character stuffing to my mail..plzz

    Reply
  5. chandana

    please send me bit unstuffing and character unstuffing programs in c

    Reply
  6. Can you please send the program for character stuffing
    program in java using client-server communication ie if client is stuffing
    the bit(as it is sender) then server will un stuff that bits (as it is receiver)
    (plz send soon)

    Reply

Leave a Reply