Program for character stuffing

Saturday, September 19th, 2009

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();
}
Avatar of Ranjith

Author Name :
Ranjith

Total : 7 Comments


7 Responses to “Program for character stuffing”

  1. payal says:

    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)

  2. satyanarayana says:

    this program should not be compile.

  3. vg says:

    pl. send byte stuffing & destuffing

  4. Siddhant says:

    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..?

  5. suresh says:

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

  6. nani says:

    hai friend can you send charecter unstuffing program

  7. ashita garg says:

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

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: