Bit Stuffing

#include<stdio.h>
#include<conio.h>
main()
{
    FILE *fp;
    int i=0;
    char ch,ch1;
    if((fp=fopen("source.txt","w"))==NULL)
    printf("\n file opening problem \n");
    printf("\n enter data to send put $ at the end \n");
    while(1)
    {
        scanf("%c",&ch);
        if(ch=='$')
        break;
        putc(ch,fp);
        if(ch=='1')
        i=i+1;
        if(ch=='0')
        i=0;
        if(i==5)
        {
            putc('0',fp);
            i=0;
        }
    }
    fclose(fp);
    fp=fopen("source.txt","r");
    printf("\n after stuffing \n");
    while((ch=getc(fp))!=EOF)
    {
        putc(ch,stdout);
    }
    printf("after de stuffing \n");
    fclose(fp);
    i=0;
    fp=fopen("source.txt","r");
    while((ch=getc(fp))!=EOF)
    {
        if(i==5)
        {
            i=0;
        }
        else
        putc(ch,stdout);
        if(ch=='1')
        i=i++;
        if(ch=='0')
        i=0;
    }
}

5 comments:

Aliya Manasa said...

Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
Python Online training
python Training in Chennai
Python training in Bangalore

sathish said...

Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training

Keerthana said...

Getting interest while reading each and every post. Thanks for sharing your valuable time with this Informative contents.To explore more Visit

python training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery

nisha said...

The blog is really very Impressive.every content should be very neatly represented.

Data Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery

Revathi said...

Very nice post here and thanks for latest smartphone applications it .I always like and such a super colors of phone for these post.Excellent and very cool idea and great models and different kinds of the more information's.Keep it up!!!

Android Training in Chennai

Android Online Training in Chennai

Android Training in Bangalore

Android Training in Hyderabad

Android Training in Coimbatore

Android Training

Android Online Training

My Favorite Books

  • C and Data Structures by Ashok N. kamthane
  • Web Technologies by A. A. Puntambekar
  • Learn HTML and CSS with W3Schools
  • Learn JavaScript and Ajax with W3Schools
  • HTML5 Black Book: Covers Css3, Javascript,XML, XHTML, Ajax, PHP And Jquery
  • HTML5 Application Development Fundamentals: MTA Exam 98-375
  • .NET 4.0 Programming 6-In-1, Black Book
  • SQL Server 2008 R2 Black Book
  • Asp.net 4.0 Projects Covers: net 3.5 And .net 4.0 Codes, Black Book
  • UNIX Shell Programming 1 Edition by Yashavant Kanetkar
  • UNIX and Shell Programming 1 Edition by Richard F. Gilberg, Behrouz A. Forouzan
  • Computer Networks by Andrew S. Tanenbaum
  • Multiple Choice questions in computer science by Timothy J Williams