Resources » Articles/Knowledge Sharing » General

Bit stuffing program in c


Last Updated:   Category: General    
Author: Member Level: Silver    Points: 2






BIT STUFFING

#include
main()
{
int n=0,i,size;
char ch,b[100];
FILE *ed;
FILE *es;
printf("enter the bit information size\n");
scanf("%d",&size);
printf("enter the information in bits\n");
for(i=0;i{
scanf("%c",&b[i]);
}
ed=fopen("info.txt","w+");
i=0;
for(i=0;i{
fputc(b[i],ed);
}
fclose(ed);
ed=fopen("info.txt","r+");
if(ed==NULL)
printf("error\n");
es=fopen("infoo.txt","w+");
ch=getc(ed);
while(ch!=EOF)
{
fputc(ch,es);
if(ch=='1')
n++;
else
n=0;
if(n==5)
{
fputc('0',es);
n=0;
}
ch=getc(ed);
}
printf("\n original data");
fclose(ed);
fclose(es);
ed=fopen("info.txt","rb+");
es=fopen("infoo.txt","rb+");



ch=getc(ed);
while(ch!=EOF)
{
printf("%c",ch);
ch=getc(ed);
}
printf("\n data after stuffing");
ch=getc(es);
while(ch!=EOF)
{
printf("%c",ch);
ch=getc(es);
}
fclose(ed);
fclose(es);
}


Did you like this resource? Share it with your friends and show your love!




Responses to "Bit stuffing program in c"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.