10-08-2011, 11:41 AM
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
char a[100],b[100];
int i,j,k,count=0;;
clrscr();
printf(" enter bits and press -1 to terminate \n");
printf("\t");
for(i=0;i<100;i++)
{
a[i]=getch();
k=a[i];
if(k!=13 && k!=48 && k!=49)
{
i--;
continue;
}
putch(a[i]);
if(a[i]==13)
break;
}
x
for(j=0;j<i;j++)
{
if(a[j]==49)
{
b[k++]=a[j];
count++;
if(count!=5)
continue;
}
if(count==5)
b[k++]='0';
else
b[k++]=a[j];
count=0;
}
printf("\n\t after stuffing:\n\n\t");
for(j=0;j<k;j++)
printf("%c",b[j]);
getch();
}