#include
#include
main()
{
char a[20],fs[50]="",t[6],r[5];
int i,j,p=0,q=0;
clrscr();
printf("enter bit string : ");
scanf("%s",a);
strcat(fs,"01111110");
if(strlen(a)<5)
{
strcat(fs,a);
}
else
{
for(i=0;i
{
for(j=i;j
{
t[p++]=a[j];
}
t[p]='\0';
if(strcmp(t,"11111")==0)
{
strcat(fs,"111110");
i=j-1;
}
else
{
r[0]=a[i];
r[1]='\0';
strcat(fs,r);
}
p=0;
}
for(q=i;q
{
t[p++]=a[q];
}
t[p]='\0';
strcat(fs,t);
}
strcat(fs,"01111110");
printf("After stuffing : %s",fs);
getch();
}
here is c code for byte stuffing......
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char da[10]="NULL",data[10]="NULL",sy='@',re[10]="NULL";
int i,n,k=0,ct=0,len,w,s=0;
clrscr();
printf("\nHeader is inserted...('@')");
printf("\nEnter string:::");
gets(da);
strcpy(data,da);
len=strlen(da);
data[0]=sy;
for(i=0;i<=len;i++)
{
data[i+1]=da[i];
}
data[len+1]=sy;
printf("\nFooter is inserted...(@)");
printf("\nYour data::");
puts(data);
len=strlen(data);
printf("The data length %d",len--);
for(i=0;i<len;i++)
{
if(data[i]==sy)
{
s++;
}
}
printf("\nThe no of symbol is %d",s);
for(i=0;i<=len;i++)
{
if(data[i]==sy && i!=0 && i!=len)
ct++;
if(ct==1 && i!=len && i!=0)
{
re[i+k]=data[i];
k++;
re[i+k]=sy;
ct=0;
}
else
re[i+k]=data[i];
}
printf("\n\n\nByte stuffing::");
puts(re);
len=strlen(re);
printf("\n\nLength=%d",len);
getch();
}
Bit stuffing has nothing to do with C Programming, although we can use C programming to implement bit stuffing.
Bit stuffing is the insertion of non-information bits into a data stream. This is typically done to ensure data streams with different bitrates are transmitted with a common bitrate or to synchronise channels prior to multiplexing.
One byte for every character.
Seek to the end of the file (fseek) and check how many bytes are in the file If the byte count is zero the file is empty.
Nothing (actually there is no BYTE in C). Use one of these: %c %x %u %o %d.
Himself. It was suicide.
C# EXAMPLEString text="My sample data";System.Text.ASCIIEncoding encode=new System.Text.ASCIIEncoding();//convert to binary and store in a byte[]byte[] binaryArray=encode.GetBytes(text);
teri bhen ki.....................
in bit stuffing we use data in bits !! in byte stuffing we use char !! thus in byte stuffing first char and converted in binary form and then bit stuffing is applied on it
The following data fragment occurs in the middle of a data stream for which the byte-stuffing algorithm described in the text is used: A B ESC C ESC FLAG FLAG D. What is the output after stuffing?
A program in c language to implement framing methods like character stuffing can be grave sizeCRC-32 and the variable c50.
In byte stuffing (or character stuffing), a special byte is added to the data section of the frame when there is a character with the same pattern as the flag. The data section is stuffed with an extra byte. This byte is usually called the escape character (ESC), which has a predefined bit pattern. Whenever the receiver encounters the ESC character, it removes it from the data section and treats the next character as data, not a delimiting flag.
Bijan Mashaw has written: 'C++ programming byte by byte' 'Programming byte by byte' -- subject(s): FORTRAN 77 (Computer program language), Structured programming 'BASIC' -- subject(s): BASIC (Computer program language)
One byte for every character.
There is not built-in 'byte' type in C, but you can define it: typedef unsigned char byte; byte bmin=0, bmax=255;
Envelope stuffing is the number one job scam.
Seek to the end of the file (fseek) and check how many bytes are in the file If the byte count is zero the file is empty.
Nothing (actually there is no BYTE in C). Use one of these: %c %x %u %o %d.
import java.io.*; class AvgWordSent { protected static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the Sentence: "); String s=in.readLine(); byte a=0,b=0; float c=0; for(byte i=0;i<s.length();i++) { if(s.charAt(i)==' ') a++; } String w[]=new String[a+1]; for(byte i=0;i<=a;i++) w[i]=""; for(byte i=0;i<s.length();i++) { if(s.charAt(i)==' ') { b++; continue; } w[b]+=s.charAt(i); } b++; for(byte i=0;i<=a;i++) c+=w[i].length(); System.out.print("Average no. of words= "+(c/b)); } }